View Full Version : <form> doing weird redirect.
SpeedFreak
08-07-2003, 05:54 PM
Hey,
i am integrating a newsletter script into the following site:
www.servicesrus.org
the form on the left hand side of the page submits the users info to the DB and that works as expected.
However, go to any other page (services, company etc...) and use the newsletter form, instead of submitting it redirects back to the index page?? and when you press reset it resets, then goes back to the index page??
Why on earth is it doing this??
the form on the index works fine, and the other forms (which have the same action, method settings etc. do not.?? They dont even get to the page they post to before being redirected?
I have been pulling my hair out about this for a while and i cant figure ot out? why is this happening??
Cheers
CrzySdrs
08-07-2003, 08:03 PM
My only guess is that the page where you upload to the database is where the problem lies. Your form sends you to newsletter/add_unsub.php?f=add_email, after that where does this add_unsub.php send you? probably right back to the default index page. I think that if you wanted it to go back to each page that it was used on then you would have to write some code for your action that does something like this.
action="newsletter/add_unsub.php?f=add_email&url=Currentpage.php"
Currentpage.php being whatever page the user is currently looking at.
then your newsletter/add_unsub.php would upload the info and redirect back to the url supplied by the action in your form.
SpeedFreak
08-07-2003, 08:14 PM
i wrote the script it posts to.
The script redirects you to the page you were visiting. It gets this info via a hidden form feild.
Also, when i try and signup via any of the pages bar the index page it doesnt add the user to the database. Almost as if it is getting redirected before it gets a chance to execute the script.
Thanks
CrzySdrs
08-08-2003, 04:18 AM
Well I think I would have to see some code before I could come up with any sort of judgement.
SpeedFreak
08-08-2003, 07:43 AM
here you go:
require("config.news.php");
//
// Add subscriber
//
function add_email(){
global $backto, $fname, $lname, $email, $header, $reply_email;
if($msg) { $msg = ""; }
$expression = "^[_A-Za-z0-9-]+@[_A-Za-z-]+(\.[A-Za-z]+)(\.[A-Za-z]+)*$";
if(empty($email) || empty($fname) || empty($lname)){
error("Please fill in all fields!");
}
if(!ereg("$expression",$email)) {
error("Invalid address");
}
$dbcnx = dbopen();
$result = mysql_query("SELECT email FROM sub_mail WHERE email ='$email'");
$num = mysql_num_rows($result);
if($num || '0') {
error("There is already a subscriber with that e-mail address in our database.");
} else {
$do = mysql_query("INSERT INTO sub_mail (email, header, fname, lname) VALUES ('$email', '$header', '$fname', '$lname')") or error(mysql_error());
mysql_close($dbcnx);
if(!$do) {
error("There was an error while adding your email into the database.");
} else {
$msg = "Subscription Successful";
error("$msg");
}
}
}
I have now removed the redirect to rule out the php and i still have the same problem.
Thanks
SpeedFreak
08-08-2003, 07:44 PM
i am sure this is not a PHP problem
anyone?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.