Jump to content


Photo

Redirect stopped working


  • Please log in to reply
5 replies to this topic

#1 Plazman65

Plazman65
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 11 April 2006 - 04:16 PM

Hi all, Im using dreamweaver to help me with somethings since I am still learning php.
I have the following code, it works great except for the fact that it doesnt redirect the user to the mydepartments page when submitted, it does add the record though. any ideas?
I appreciate the help, thanks, Michelle
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="style1" id="form1">
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if
(
($_SESSION['mem_type']=="standard" && $_SESSION['count']>=5)||
($_SESSION['mem_type']=="silver" && $_SESSION['count']>=10)||
($_SESSION['mem_type']=="gold" && $_SESSION['count']>=25)){
echo "You have exceeded your maximum number of Departments. ".
"Please edit your departments or consider upgrading your account.";
}


else
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO mydepartments (username, depid, mem_type) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['username2'], "text"),
GetSQLValueString($_POST['depid2'], "int"),
GetSQLValueString($_POST['textfield'], "text"));

mysql_select_db($database_jobs, $jobs);
$Result1 = mysql_query($insertSQL, $jobs) or die(mysql_error());

$insertGoTo = "../mydepartment/mydepartments.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 April 2006 - 04:20 PM

Do yourself a favour. Drop Dreamweaver. That code is horrible, and really, its not making your learning process any eaiser.

Anyway... try some debuging. Add this line...
echo $insertGoTo; die();
Just before...
header(sprintf("Location: %s", $insertGoTo));
What does it display?

#3 Plazman65

Plazman65
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 11 April 2006 - 04:26 PM

[!--quoteo(post=363702:date=Apr 11 2006, 08:20 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 11 2006, 08:20 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Do yourself a favour. Drop Dreamweaver. That code is horrible, and really, its not making your learning process any eaiser.

Anyway... try some debuging. Add this line...
echo $insertGoTo; die();
Just before...
header(sprintf("Location: %s", $insertGoTo));
What does it display?
[/quote]

Ohh good idea, you guys are so smart, ok I got this-

../mydepartment/mydepartments.php?CITY=Kwethluk

CITY=Kwethluk - this part comes from the fact that its being passed via url, now i just need to find that bit and get rid of that and it should work right?
Thanks for your help, Michelle


#4 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 11 April 2006 - 04:58 PM

I'm with thorpe on dreamweaver. Never used it, never will and I've nicknamed it dreamwrecker :)

Back to your code.

If you're already in the folder "mydepartment" then there's no need that I can see to be specifying "../mydepartment/" in the variable.

Removing everything after the ? won't make much difference as its just passing parameters to the script mentioned. Try removing "../mydepartment/" and just have:
$insertGoTo = "mydepartments.php";
See how that goes.
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#5 Plazman65

Plazman65
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 11 April 2006 - 05:58 PM

[!--quoteo(post=363722:date=Apr 11 2006, 08:58 AM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 11 2006, 08:58 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'm with thorpe on dreamweaver. Never used it, never will and I've nicknamed it dreamwrecker :)

Back to your code.

If you're already in the folder "mydepartment" then there's no need that I can see to be specifying "../mydepartment/" in the variable.

Removing everything after the ? won't make much difference as its just passing parameters to the script mentioned. Try removing "../mydepartment/" and just have:
$insertGoTo = "mydepartments.php";
See how that goes.
[/quote]\
the passing variable makes sense but the page is in another folder so I would need to incldue the whole path.
Someone jsut really confused me and said that I cant do
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="style1" id="form1">
<?php <-- with this inside the form

Is that right?

#6 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 11 April 2006 - 06:02 PM

[!--quoteo(post=363734:date=Apr 11 2006, 12:58 PM:name=plazman65)--][div class=\'quotetop\']QUOTE(plazman65 @ Apr 11 2006, 12:58 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
\
the passing variable makes sense but the page is in another folder so I would need to incldue the whole path.
Someone jsut really confused me and said that I cant do
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="style1" id="form1">
<?php <-- with this inside the form

Is that right?
[/quote]


I do that all the time...







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users