Forum Moderators: coopster
$sql = "INSERT INTO author SET
firstname='$name1',
lastname='$name2',
workphone='$workphone',
email='$email',
loginid='$loginid',
password='$password'";
if (@mysql_query($sql)) {
header("Location: formSubmit.htm"); <--------HERE
I would appreciate any help I can get.
thanks
I have a form inside an .html file that collects data from user. The form tag calls the .php file that you see part of in this thread and passes all variable data to it for posting to mySQL database. At the bottom of php code (shown) there is the if , else. If the post is successful, I simply wanted to dispay another formatted .html file that says the users data was accepted ok and displays the data entered for review. Otherwise dislay an error in a different .html page.
Thanks again..
1. use output buffering [us3.php.net]
2. handle it programmatically. To do that, you basically just assign your output to a variable or set of variables. So instead of
echo "The first thing I want to say";
echo "The second thing I want to say";
you use
$content = ""; // first we initialize our variable
...
$content .= "The first thing I want to say";
$content .= "The second thing I want to say";
Then, at the end of the script
echo $content;
Either way will work as will both together.
[SNIP html header]
<?php if (isset($_GET['lastname'])):?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<table border="0" cellspacing="6" cellpadding="0">
<tr><td>First Name</td></tr>
[SNIP many similar rows]
<tr><td><input type="submit" name="Submit" value="Send">
<input type="reset" name="Submit2" value="Reset Form"></td></tr>
</table>
</form>
<?php else:
$dbcnx = @mysql_connect('localhost', 'codemake_codemak', '$code$');
If (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
If (!@mysql_select_db('codemake_helpdesk')) {
exit('<p>Unable to locate the Helpdesk ' .
'database at this time.</p>');
}
if (isset($_POST['lastname'])) {
$name1 = $_POST['firstname'];
$name2 = $_POST['lastname'];
$workphone = $_POST['workphone'];
$email = $_POST['email'];
$loginid = $_POST['loginid'];
$password = $_POST['password'];
$sql = "INSERT INTO author SET
firstname='$name1',
lastname='$name2',
workphone='$workphone',
email='$email',
loginid='$loginid',
password='$password'";
if (@mysql_query($sql)) {
echo '<p>New Author Added</p>';
} else {
echo '<p>Error adding new author: ' .
mysql_error() . '</p>';
}
}
endif;
?>
<p class="copyrights">Lorem ipsum dolor
[SNIP - lots of text]
</p>
[edited by: ergophobe at 12:15 am (utc) on Jan. 7, 2005]
[edit reason] code dump snipped - please read forum charter [/edit]