Jump to content

[SOLVED] Problem with a "Stay Updated" script


DBookatay

Recommended Posts

I am trying to make a form on my site (http://www.carcityofdanbury.com/inventory.php?status=Error#StayUpdated) where a user enters their email address if they wish to recieve emails when my site is updated, but I'm obviously doing something incorrect, cause the script keeps failing. Can someone show/ tell me what is wrong?

 

The HTML

									<table>
										<tr class="title225"><td height="23" style="padding-left:10px"><a id="StayUpdated"></a><span class="subTitle">Stay Updated</span></td></tr>
										<tr><td class="ContHldr">
											<form action="inventory.php" name="form" method="post" class="no">
											<div align="center">
												<table>
													<tr><td class="frmPad">Want to say updated with all<br />the changes made on our site?</td></tr>
													<tr><td style="padding-top:10px"><? echo $update_errors ?><input name="updated" type="text" class="input" size="30" onclick="if(this.value=='Enter Email Address'){this.value=''}" value="Enter Email Address" /></td></tr>
													<tr><td align="center" style="padding-top:10px"><input type="image" src="images/Default/BTNs/signupOff.gif" srcover="images/Default/BTNs/signupOn.gif" name="submit" /></td></tr>
												</table>
											</div>
											</form>
										<tr><td><img src="images/Default/Titles/btm225.gif" /></td></tr>
									</table>

 

The PHP:

	if(!(empty($_POST['updated']))) { 
	if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})", $_POST['updated']))
	{
		$email = $_POST['updated']; 
	}
	else {
		$email = 'Enter Email Address'; 
	}
}


if ($email == "Enter Email Address") {
	echo '<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>';
} else {
	$querySubmit;
}

$querySubmit = mysql_query("INSERT INTO RecieveUpdates (email) VALUES ('$email')")or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=inventory.php?status=Good\">";

 

(I know that the code is much longer and hacked togather than it needs to be, but I am a self admitted "NOOB!")

 

 

Link to comment
Share on other sites

oh my mistake then, i didnt know it was a button.

 

use

 

if(isset($_POST['updated'])){
	if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})", $_POST['updated']))
	{
		$email = $_POST['updated']; 
	}
	else {
		$email = 'Enter Email Address'; 
	}



if ($email == "Enter Email Address") {
	echo '<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>';
} else {
	$querySubmit;
}

$querySubmit = mysql_query("INSERT INTO RecieveUpdates (email) VALUES ('$email')")or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=inventory.php?status=Good\">";

}

 

Link to comment
Share on other sites

      try

 

f(isset($_POST['updated'])){
	if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})", $_POST['updated']))
	{
		echo '<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>';

	}
	else{		
	$email = $_POST['updated'];			
	$querySubmit;	
	$querySubmit = mysql_query("INSERT INTO RecieveUpdates (email) VALUES ('$email')")or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=inventory.php?status=Good\">";

}

}

Link to comment
Share on other sites

       try

 

f(isset($_POST['updated'])){
	if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})", $_POST['updated']))
	{
		echo '<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>';

	}
	else{		
	$email = $_POST['updated'];			
	$querySubmit;	
	$querySubmit = mysql_query("INSERT INTO RecieveUpdates (email) VALUES ('$email')")or die(mysql_error()); echo "<meta http-equiv=\"Refresh\" content=\"0; url=inventory.php?status=Good\">";

}

}

 

Thats it, thanks...

Link to comment
Share on other sites

Looking at the script you created, leaves me with a question I always wondered.

I used to use the redirect php script

echo "<meta http-equiv="Refresh" content="0; url=inventory.php?status=Good">

 

but it seams like the java version

<HEAD><SCRIPT language="JavaScript1.1">location.replace("inventory.php?status=Error#StayUpdated");</SCRIPT></HEAD>

works much quicker.

 

Anyone care to comment?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.