Jump to content

Redirect stopped working


Plazman65

Recommended Posts

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));
}
?>
Link to comment
Share on other sites

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...
[code]
echo $insertGoTo; die();
[/code]
Just before...
[code]
header(sprintf("Location: %s", $insertGoTo));
[/code]
What does it display?
Link to comment
Share on other sites

[!--quoteo(post=363702:date=Apr 11 2006, 08:20 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 11 2006, 08:20 AM) [snapback]363702[/snapback][/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...
[code]
echo $insertGoTo; die();
[/code]
Just before...
[code]
header(sprintf("Location: %s", $insertGoTo));
[/code]
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
Link to comment
Share on other sites

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:
[code]$insertGoTo = "mydepartments.php";[/code]
See how that goes.
Link to comment
Share on other sites

[!--quoteo(post=363722:date=Apr 11 2006, 08:58 AM:name=Yesideez)--][div class=\'quotetop\']QUOTE(Yesideez @ Apr 11 2006, 08:58 AM) [snapback]363722[/snapback][/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:
[code]$insertGoTo = "mydepartments.php";[/code]
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?
Link to comment
Share on other sites

[!--quoteo(post=363734:date=Apr 11 2006, 12:58 PM:name=plazman65)--][div class=\'quotetop\']QUOTE(plazman65 @ Apr 11 2006, 12:58 PM) [snapback]363734[/snapback][/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...


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.