Hi All,
I've just spent the last 2 days trying to figure out how to collect a visitors email address on my homepage and their contact info on the second page in the same table of MySQL database.
Here's the simple version of the code I've been working on:
Page 1 Code:
<form name="test" action="page2.php" method="POST">
Enter your email address: <input type="text" name="email" />
<input type="submit" />
</form>
Page 2 Code:
Welcome <?php echo $_POST["email"]; ?>.<br />
<form action="page3.php" method="POST">
Enter your name: <input type="text" name="name" />
<input type="submit" />
</form>
Page 3 Code:
<?php
$DBhost = "mysql15.secureserver.net";
$DBuser = "nanovation";
$DBpass = "Red1";
$DBName = "nanovation";
$table = "visitors";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$email','$name')";
$results = mysql_query($sqlquery);
mysql_close();
?>
Result:
Neither the email address nor name are collected into the table. Only when I ask for the visitors email and name on the same page, do they both get entered into the database. :bemused:
Any help would be appreciated.
Sincerely,
Nanovation