Run the following code to create your table, and then discard:
PHP Code:
<?php
$dbhost = "puttforpresents.local";
$dbuser = "root";
$dbpass = "";
$dbname = "pfp";
if (!mysql_connect($dbhost, $dbuser, $dbpass))
die("Can't connect to database");
if (!mysql_select_db($dbname))
die("Can't select database");
mysql_query("CREATE TABLE golfers(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
firstname VARCHAR (50),
lastname VARCHAR (50),
email VARCHAR (50),
phone VARCHAR (30),
handicap INT)")
or die(mysql_error());
mysql_close;
?>
register.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Putt for Presents</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include('header.php'); ?>
<div id="registrationtitles">
<h2>First Name:</h2>
<h2>Last Name:</h2>
<h2>E-mail:</h2>
<h2>Phone:</h2>
<h2>Handicap:</h2>
<h2>Select your team:</h2>
</div>
<div id="registrationinputs">
<form id="register" name="register" method="post" action="handleinput.php">
<input type="text" name="firstname" id="firstname" /><br />
<input type="text" name="lastname" id="lastname" /><br />
<input type="text" name="email" id="email" /><br />
<input type="text" name="phone" id="phone" /><br />
<select name="handicap" size="1" id="handicap">
<option>0</option>
<option>5</option>
<option>10</option>
<option>15</option>
<option>20</option>
<option>25</option>
</select>
<br>
<input name="submit" type="submit" value="Submit" />
</form>
</div>
</body>
</html>
handleinput.php
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Putt for Presents</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p><img src="img/PuttforPresentsLogo.jpg" width="625" height="200" alt="PFP Logo" />
<?php
$dbhost = "puttforpresents.local";
$dbuser = "root";
$dbpass = "";
$dbname = "pfp";
$table = "golfers";
if (!mysql_connect($dbhost, $dbuser, $dbpass))
die("Can't connect to database");
if (!mysql_select_db($dbname))
die("Can't select database");
mysql_query("INSERT INTO $table (
firstname,
lastname,
email,
phone,
handicap
)
VALUES (
$firstname,
$lastname,
$email,
$phone,
$handicap
)");
mysql_close;
echo'<head><title>PHP and MySQL</title></head><body bgcolour="#FFFFFF"><center><table border="0" width="500"><tr><td><font face="verdana" size="+0"><center><p>You just entered this information into the database</p><p>Name : $firstname</p><p>Last Name : $lastname</p><p>E-Mail : $email</p></center></td></tr></table></body>';
?>
</body>
</html>
Bookmarks