PHP Code:<?php
$db_host = "localhost";
$db_user = "";
$db_pwd = " ";
$db_name = "";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<html>
<head>
<title>Profile</title>
</head>
<body>
<?php
if (!isset($_POST['submit'])) {
?>
<form action="" method="post">
First Name: <input type="text" name="name"><br>
Last Name: <input type="text" name="lname"><br>
Age: <input type="text" name="age"><br>
Fav Color: <input type="text" name="color"><br>
Best Friend: <input type="text" name="friend"><br>
# Of Pets: <input type="text" name="pet"><br>
# Of Siblings: <input type="text" name="sib"><br>
Fav Town: <input type="text" name="ftown"><br>
Home Town: <input type="text" name="htown"><br>
Status: <input type="text" name="stat"><br>
Gender: <input type="text" name="sex"><br>
Grade: <input type="text" name="gr"><br>
<input type="submit" name="submit" value="Submit!">
</form>
<?php
} else {
$name = $_POST['name'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$color = $_POST['color'];
$friend = $_POST['friend'];
$sib = $_POST['sib'];
$ftown = $_POST['ftown'];
$htown = $_POST['htown'];
$stat = $_POST['stat'];
$sex = $_POST['sex'];
$gr = $_POST['gr'];
mysql_query("INSERT INTO `profile` (name, lname, age, color, friend, sib, ftown, htown, stat, sex, gr) VALUES ('$name', '$lname', '$age', '$color', '$friend', '$sib', '$ftown', '$htown', '$stat', '$sex', '$gr',)");
echo "Success! Your Profile has been added!";
}
?>
</body>
</html>





Reply With Quote

