Created
May 14, 2013 23:01
-
-
Save jnewman12/5580395 to your computer and use it in GitHub Desktop.
Went to General Assembly over the weekend. We covered html, css, a little javascript (wish it could have been more), PHP & MySQL and also got to learn to use cyberduck for a host. The purpose of this was to build a simple contact page that allowed people to fill in a box with their; name, email, and leave a message which would go to my email. It…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = 'pfnppublic.pfnp.ccastig.com'; // hostname | |
$username = 'pfnpclass';//username from HG | |
$pass = 'ptx!fy8h'; //password from HG | |
$dbname = 'pfnpclass'; // Database Name | |
$conn = mysql_connect($host, $username, $pass) or die(mysql_error()); | |
if ($conn) | |
{ | |
mysql_select_db($dbname) or die(mysql_error()); | |
} | |
else | |
{ | |
echo 'Connection failed.'; | |
} | |
/* 1. Catch the data with variables */ | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
$message = $_POST['message']; | |
// test | |
/* 2. Send mail */ | |
$to = "james102191@yahoo.com"; | |
$subject = "New Message From Your Site"; | |
$message = "You have a new message from $name ($email): $message"; | |
$headers = "From: info@ccastig.com"; | |
mysql_query("INSERT INTO teamnewman_users(name, email, message) VALUES('$name', '$email', '$message') ") or die(mysql_error()); | |
mail($to, $subject, $message, $headers); | |
/* 3. Tell the user "Thank you" */ | |
header("Location: thankyou.html"); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="description" content="Your description goes here"> | |
<meta name="keywords" content="one, two, three"> | |
<title>James Newman</title> | |
<!-- external CSS link --> | |
<link rel="stylesheet" href="css/normalize.css"> | |
<link rel="stylesheet" href="css/style.css"> | |
<!-- Include jQuery --> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
</head> | |
<body> | |
<div id="container" class="myform"> | |
<!-- EDIT HTML CODE BEGIN --> | |
<div id="header"> | |
<h1>James Newman</h1> | |
</div> | |
<div id="main" class="clearfix"> | |
<h2>Contact Me</h2> | |
<form action="process.php" method="post"> | |
<div class="row"> | |
<!-- "for" attribute matches "input's id" --> | |
<label for="form_name">Name:</label> | |
<input id="form_name" type="text" name="name"> | |
</div> | |
<div class="row"> | |
<label for="form_email">Email:</label> | |
<input id="form_email" type="text" name="email"> | |
</div> | |
<div class="row"> | |
<label for="form_message">Message:</label> | |
<textarea id="form_message" name="message"></textarea> | |
</div> | |
<button type="submit" value="Save" class="btn">Submit</button> | |
</form> | |
</div> | |
<div class="clear"></div> | |
<div id="footer"> | |
<a href="http://www.twitter.com/call_me_newman">Twitter: @call_me_newman</a> | |
</div> | |
<!-- EDIT HTML CODE END --> | |
</div><!-- #container --> | |
<script src="js/validation.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="description" content="Your description goes here"> | |
<meta name="keywords" content="one, two, three"> | |
<title>James Newman</title> | |
<!-- external CSS link --> | |
<link rel="stylesheet" href="css/normalize.css"> | |
<link rel="stylesheet" href="css/style.css"> | |
<!-- Include jQuery --> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
</head> | |
<body> | |
<div id="container" class="myform"> | |
<!-- EDIT HTML CODE BEGIN --> | |
<div id="header"> | |
<h1>James Newman</h1> | |
</div> | |
<div id="main" class="clearfix"> | |
<h2>Thank You</h2> | |
</div> | |
<div class="clear"></div> | |
<div id="footer"> | |
<a href="http://www.twitter.com/call_me_newman">Twitter: @call_me_newman</a> | |
</div> | |
<!-- EDIT HTML CODE END --> | |
</div><!-- #container --> | |
<script src="js/validation.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment