Jump to content

Not redirecting correctly


HDFilmMaker2112

Recommended Posts

For some reason the below is always redirecting to ./index.php?usercp=ideas&message=error

 

I'm assuming it's something to do with mysql_affected_rows.

 

<?php
session_start();
require_once 'db_select.php';
require_once 'func.php';
$donor_id=$_POST['donor_id'];
$donor_id=sanitize($donor_id);
$username=$_POST['username'];
$username=sanitize($username);
$name=$_POST['name'];
$name=sanitize($name);
$amount=$_POST['amount'];
$amount=sanitize($amount);
$idea_message=$_POST['idea_message'];
$idea_message=sanitize($idea_message);
$_SESSION['idea_message']=$idea_message;
$subject=$_POST['subject'];
$subject=sanitize($subject);
$_SESSION['subject']=$subject;
$confirm_agreement=$_POST['confirm_agreement'];
$confirm_agreement=sanitize($confirm_agreement);


if($subject==""){
$error0=1;
}
else{
$error0=0;
}

if($idea_message==""){
$error1=1;
}
else{
$error1=0;
}

if(($confirm_agreement!="no" && $confirm_agreement!="yes") || $confirm_agreement=="no"){
$error2=1;
}
else{
$error2=0;
}

$error="".$error0."".$error1."".$error2."";

if($error!="000"){
header("Location: ./index.php?usercp=ideas&error=".$error."");
}
else{
$sql="INSERT INTO $tbl_name5 (message_number, donor_id, username, name, amoutn, message) VALUES ('$message_number', '$donor_id', '$username', '$name', '$amount', '$message')";
mysql_query($sql);
if(mysql_affected_rows()==1){
header("Location: ./index.php?usercp=ideas&message=submitted");
unset($_SESSION['idea_message']);
unset($_SESSION['subject']);
}
else{
header("Location: ./index.php?usercp=ideas&message=error");
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/251340-not-redirecting-correctly/
Share on other sites

Well, your code says that if mysql_affected_rows() != (does not equal) 1, then it will use the header url of the one you specified. So that indicates mysql_affected_rows() is not equaling 1, when you think it should be.

 

Ask yourself why that is?

 

TIP: mysql_query($sql) or die(mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.