I want thank all who helped with the issue I was having with the password, so I figured it out. The problem I am having now is info is submitted from form 1, at form two which is the code below, it does not show the info for user to verify before it writes to the DB. I'm figuring I am miss using else if statements or something. I new to php, and learning.
So what the code below does, is it verifies to make sure all fields are filled in, but if all fields are filled in, it is suppose to show the user what they put in. So if all is correct with the user they hit the submit button and then I want it to write to the DB.
Any help is greatly appreciated. Thanks
<html>
<head></head>
<body>
<?php
if(isset($_POST['submit'])) {
echo "Please verify your information that you entered:<br><br>
First Name:".$_POST['first_name']."<br>
Last Name:".$_POST['last_name']."<br>
Street Address:".$_POST['street_address']."<br>
City:".$_POST['city']."<br>
State:".$_POST['state']."<br>
Zip Code:".$_POST['zipcode']."<br>
Phone Number:".$_POST['phone_number']."<br>
User Name:".$_POST['username']."<br>
Password:".$_POST['password']."<br>
Email:".$_POST['email']."<br>";
}
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="first_name" value="<? $_POST['first_name']; ?>">
<input type="hidden" name="last_name" value="<? $_POST['last_name']; ?>">
<input type="hidden" name="street_address" value="<? $_POST['street-address']; ?>">
<input type="hidden" name="city" value="<? $_POST['city']; ?>">
<input type="hidden" name="state" value="<? $_POST['state']; ?>">
<input type="hidden" name="zipcode" value="<? $_POST['zipcode']; ?>">
<input type="hidden" name="phone_number" value="<? $_POST['phone_number']; ?>">
<input type="hidden" name="username" value="<? $_POST['username']; ?>">
<input type="hidden" name="password" value="<? $_POST['password']; ?>">
<input type="hidden" name="email" value="<? $_POST['email']; ?>">
<input type="submit" value="submit">
<?php
// form submitted
// server accesss variables
include("dbinfo2.php");
//make sure all fields are filled in
$firstname = empty($_POST['first_name']) ? die ("Error: Enter your First Name") :
mysql_escape_string($_POST['first_name']);
$lastname = empty($_POST['last_name']) ? die ("Error: Enter your Last Name") :
mysql_escape_string($_POST['last_name']);
$address = empty($_POST['street_address']) ? die ("Error: Enter your Street Address") :
mysql_escape_string($_POST['street_address']);
$city = empty($_POST['city']) ? die ("Error: Enter your City") :
mysql_escape_string($_POST['city']);
$state = empty($_POST['state']) ? die ("Error: Enter your State") :
mysql_escape_string($_POST['state']);
$zipcode = empty($_POST['zipcode']) ? die ("Error: Enter your Zipcode") :
mysql_escape_string($_POST['zipcode']);
$phonenumber = empty($_POST['phone_number']) ? die ("Error: Enter your Phone Number") :
mysql_escape_string($_POST['phone_number']);
$username = empty($_POST['username']) ? die ("Error: Enter your User Name") :
mysql_escape_string($_POST['username']);
$password = (md5($password));empty($_POST['password']) ? die ("Error: Please enter a Password"):
mysql_escape_string($_POST['password']);
$email = empty($_POST['email']) ? die ("Error: Enter your Email") :
mysql_escape_string($_POST['email']);
//open connection to db
$connection = mysql_connect($host, $user, $pw) or die ("Unable to Connect");
//select db
mysql_select_db($db) or die ("Unable to select database!");
//create query
$query = "INSERT INTO users (first_name, last_name, street_address, city, state, zipcode,
phone_number, username, password, email) VALUES ('$firstname', '$lastname', '$address', '$city',
'$state', '$zipcode', '$phonenumber', '$username', '$password', '$email')";
//execute query
$result = mysql_query($query) or die ("Error in query: $quesry. ".mysql_error());
//print message with ID
echo "New record inserted with ID ".mysql_insert_id();
//close connection
mysql_close($connection);
?>
</form>
</body>
</html>