I don't know why this isn't working for me. It is essentially a copy of another script I have working but scaled down.
I have form asking for email and name.
It runs it through the sign-up script.
I know the page is properly connected to the db because if I try to use the only email entry that exists in the db, it knows that it is being used.
The issue is somewhere withing the actual insert area of the code.
- Code: Select all
<?
if(isset($todo) and $todo=="post"){
$status = "OK";
$msg="";
// if userid is less than 3 char then status is not ok
if(!isset($email) or strlen($email)<3){
$msg=$msg."You must enter an existing email address<BR>";
$status= "NOTOK";}
if(mysql_num_rows(mysql_query("SELECT email FROM newsletter WHERE email = '$email'"))){
$msg=$msg."Email already exists in our database. Thank-you for having signed up.<BR>";
$status= "NOTOK";}
if(!isset($name) or strlen($name) <2){
$msg=$msg."Name should be at least 2 characters in length<BR>";
$status= "NOTOK";}
if ($agree<>"yes") {
$msg=$msg."You must agree to <a href=tandc.php>terms and conditions</a><BR>";
$status= "NOTOK";}
if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{ // if all validations are passed.
$query=mysql_query("insert into newsletter(email,name) values('$email','$name')");
echo "<font face='Verdana' size='2' color=green>Thank-you for signing-up, we will e-mail you for the launch of nnjoi.com. </font> <br /><br /><br /> <a href=index.php>Home</a>";
}
}
?>
and here is the form that inputs it:
- Code: Select all
<span class="sub">Sign-up to keep up to date on nnjoi.com's launch date. </span><br />
<form name="form1" method="post" action="signupnews.php" onsubmit='return validate(this)'><input type=hidden name=todo value=post>
<table border=0 cellpadding="2px" cellspacing="2px" align="left" width="400px">
<tr><td>Email:</td><td><input name="email" type="text" size="17" maxlength="50" /></td></tr>
<tr><td>Name:</td><td><input name="name" type="text" size="17" maxlength="20" /></td></tr>
<tr><td>I agree to <a href="tandc.php target="_blank"">terms and conditions</a></td><td><input type=checkbox name=agree value='yes'></td></tr>
<tr><td></td><td><input type="submit" value="Submit" /></td></tr>
</table>
</form>



