I’m having a slight problem with my script and redirecting it back to the form.
The script connects to the MySQL 5.0 database (i know this works), collects and “sanatizes” a bunch of $_POST variables (i know the data is passed and collected), writes a valid INSERT statement, and mysql_query($insert)’s the data to the database (I know it does that, too).
The header ( “Location: ); doesn’t want to send it back to the form.
[code=php]
$insert = “INSERT INTO `table1` ( `eventID` , `currentEvent` , `eventTitle` , `eventDate` , `eventLocation` , `eventTime` , `eventDetails` , `dinnerLocation` , `dinnerTime` , `dinnerDetails` , `eventRSVP` , `notes` )
VALUES (
”, ‘0’, ‘$eventTitle’, ‘$eventDate’, ‘$eventLocation’, ‘$eventTime’, ‘$eventDetails’, ‘$dinnerLocation’, ‘$dinnerTime’, ‘$dinnerDetails’, ‘$eventRSVP’, ‘$eventFile’
)”;
$update=mysql_query($insert);
if(!$update) {
if(!mysql_num_rows($update)==1) {
echo “<p>update failed</p>”;
die(mysql_error());
}
else {
header ( “Location: http://www.aicwisconsin.com/dev/addevent.php”);
}
}
This (used to) be almost a carbon-copy of another script that does work, which is why I’m extra confused. I’ve been staring at this too long, that my novice brain is throwing up the proverbial white flag.
full [cleaned] code below:
[code=php]
// database connection
// Open a connection to the MySQL database server
$link = mysql_connect(‘host’,’user’,’pass’);
if (!$link)
exit(‘Connection to MySQL server failed!’);
//Select database
$db=mysql_select_db(“database”);
if(!$db) {
die(“Unable to select database”);
}
//Sanitize the value received from login field to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
$eventTitle=mysql_real_escape_string($_POST[‘eventTitle’]);
}else {
$eventTitle=$_POST[‘eventTitle’];
}
// etc for all remaining variables.
$postback = $_POST[‘postback’];
$insert = “INSERT INTO `table1` ( `eventID` , `currentEvent` , `eventTitle` , `eventDate` , `eventLocation` , `eventTime` , `eventDetails` , `dinnerLocation` , `dinnerTime` , `dinnerDetails` , `eventRSVP` , `notes` )
VALUES (
”, ‘0’, ‘$eventTitle’, ‘$eventDate’, ‘$eventLocation’, ‘$eventTime’, ‘$eventDetails’, ‘$dinnerLocation’, ‘$dinnerTime’, ‘$dinnerDetails’, ‘$eventRSVP’, ‘$eventFile’
)”;
$update=mysql_query($insert);
if(!$update) {
if(!mysql_num_rows($update)==1) {
echo “<p>update failed</p>”;
die(mysql_error());
}
else {
header ( “Location: http://www.aicwisconsin.com/dev/addevent.php”);
}
}
else {
die(mysql_error());
}