Hi all,
I'm currently designing a jobs site which requires a lot of
PHP/MySQL work.
Now, I'm not really an expert at either but as I'm the only one in our company who is more familiar with
PHP (everyone else is experienced with
ASP, .NET etc.) I've been given the job.
I'm using Dreamweaver to help with producing the queries, code etc. (sssh

) and I'm stuck on one particular thing.
I'm working on the newsletter page, where someone inputs their email address and submits it to the database. That all works fine, but when I click submit it throws me this error (even though the data does get stored in the database)
Quote:
|
Warning: Cannot modify header information - headers already sent by (output started at /home/.rover/emzi/enjoyonline.co.uk/dev/ukjobs/includes/latestjobs.php:52) in /home/.rover/emzi/enjoyonline.co.uk/dev/ukjobs/includes/newsletter.php on line 53
|
The
PHP code is here:
- PHP: Select all
<?php require_once('Connections/ukjobsite.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblNEWSLETTER_SIGNUP (signup_id, email_address, date_registered, client_ip, unsubscribed) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['signup_id'], "int"),
GetSQLValueString($_POST['email_address'], "text"),
GetSQLValueString($_POST['date_registered'], "date"),
GetSQLValueString($_POST['client_ip'], "text"),
GetSQLValueString($_POST['unsubscribed'], "int"));
mysql_select_db($database_ukjobsite, $ukjobsite);
$Result1 = mysql_query($insertSQL, $ukjobsite) or die(mysql_error());
$insertGoTo = "newsletter_signup_success.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<img src="images/grey_small_top.gif" alt="UK Jobs in Recruitment" /><div class="grey_small">
<div class="small_content_holder"><img src="images/newsletter.gif" alt="UK Jobs in Recruitment" /><br />
Submit your email address to sign up to our
newsletter.<br />
<div class="form_text">
<div class="form_padding"><b>Email:</b></div>
</div>
<div class="form_object">
<div class="form_padding">
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"><input name="email_address" type="text" class="textfield"/></div>
<input type="submit" class="submit" value="SUBMIT" /> <input type="hidden" name="signup_id" value="" />
<input type="hidden" name="client_ip" value="<?php echo $_SERVER['REMOTE_ADDR'] ?>" />
<input type="hidden" name="unsubscribed" value="0" />
<input type="hidden" name="MM_insert" value="form1" />
</form></div><div class="clear"></div></div></div><img src="images/grey_small_bot.gif" alt="UK Jobs in Recruitment" />
The particular line in question is:
- PHP: Select all
}
header(sprintf("Location: %s", $insertGoTo));
And the site is here:
http://www.dev.enjoyonline.co.uk/ukjobs/
Thanks in advance for any help!
