Plazman65 Posted April 11, 2006 Share Posted April 11, 2006 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.";}elseif ((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));} ?> Quote Link to comment Share on other sites More sharing options...
trq Posted April 11, 2006 Share Posted April 11, 2006 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 Link to comment Share on other sites More sharing options...
Plazman65 Posted April 11, 2006 Author Share Posted April 11, 2006 [!--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=KwethlukCITY=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 Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 11, 2006 Share Posted April 11, 2006 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 Link to comment Share on other sites More sharing options...
Plazman65 Posted April 11, 2006 Author Share Posted April 11, 2006 [!--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 formIs that right? Quote Link to comment Share on other sites More sharing options...
AV1611 Posted April 11, 2006 Share Posted April 11, 2006 [!--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 formIs that right?[/quote]I do that all the time... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.