Nacota Posted September 29, 2009 Share Posted September 29, 2009 This is continuing problem for me what I have is a form that once filled out should redirect to the homepage but isnt working can you see any problems with this code? both bits of code are in different pages one is an .inc page with the stored data not sure what is wrong <? include('SignUp/questconfig.inc'); if ($redirecturl != "") { header("Location: $redirecturl"); } else { echo "<br><center>$finishedtext</center><br>"; } ?> data from SignUp/questconfig.inc : <? # url the form will redirect to after sending email $redirecturl = "www.site.com"; # text that will display if you leave above variable blank $finishedtext = "Thank you for your interest, We will be contacting you soon!"; ?> Thank you for helping! Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 29, 2009 Share Posted September 29, 2009 Add the following two lines of code immediately after your first opening <?php tag on the main page - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927251 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 It's possible that you have short_open_tag set to false in your php.ini. Your redirect wouldn't have completed correctly without the http:// part of the url. This code should work. <?php include('SignUp/questconfig.inc'); if ($redirecturl != "") { header("Location: $redirecturl"); exit(); } else { echo "<br><center>$finishedtext</center><br>"; } ?> <?php # url the form will redirect to after sending email $redirecturl = "http://www.site.com"; # text that will display if you leave above variable blank $finishedtext = "Thank you for your interest, We will be contacting you soon!"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927254 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 ok I did that and now theres errors all over my form page about the config.inc page? but what its pointing out is right (I think) $msg2 = " >> Name: $ContactName >> Company: $CompanyName >> Position: $YourPosition >> Email: $ContactEmail "; EDIT:: Notice: Undefined variable: ContactName in SignUp/questconfig.inc on line 56 error Im getting is what I have where its throwing the errors where the ">>" is and the ">>" is not there in the real page this $msg2 is the data that gets mailed to me and is only be here as a reference to the order inside the email I get should this look like the main page as: $ContactName = $_POST[ContactName]; Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927259 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 It's possible that you have short_open_tag set to false in your php.ini. Your redirect wouldn't have completed correctly without the http:// part of the url. This code should work. <?php include('SignUp/questconfig.inc'); if ($redirecturl != "") { header("Location: $redirecturl"); exit(); } else { echo "<br><center>$finishedtext</center><br>"; } ?> <?php # url the form will redirect to after sending email $redirecturl = "http://www.site.com"; # text that will display if you leave above variable blank $finishedtext = "Thank you for your interest, We will be contacting you soon!"; ?> ok well the http:// was up there, Ive tried it both ways but I see exit() after is that needed? Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927260 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 ok well the http:// was up there, Ive tried it both ways but I see exit() after is that needed? If you say so, though http:// is included nowhere in your first post. The exit() strictly speaking in your case might not be required, it is however best practice. After sending a Location header, the script does keep running, which is something you don't actually want to happen. If you have no other code below it doesn't espcially matter, but if you have a full script below, you don't want it running. Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927272 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 yes your right I didnt say anything about it here "up there" meaning the server, sorry on the exit() that makes sense, end what donsnt need to run I have put in the exit(), and the http:// however it still dosen't work I have updated my other post with the error I am getting any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927294 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 People will debate all day about whether you should solve or ignore Notices, but one thing thats fairly certain, they are not what are stopping your code working. If you copy the code I posted and just the code I posted into the two respective files, it will work (the caveat being that I used a .php extention for the included file, depending on your server settings it might not parse PHP in the .inc file correctly) . If your code is not working there is something else in your script causing the problems. Without seeing the whole script I'd need a magic ball to work out what exactly that might be. Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927300 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 Ill send you a pm cags thank you! Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927302 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 first page the customer comes to is signup.php <? #ini_set("display_errors", "1"); #error_reporting(E_ALL); ######################################################### # ContactForm # ######################################################### # # # Created by: Doni Ronquillo # # Modified by: CodeMunkyX # # # # This script and all included functions, images, # # and documentation are copyright 2003 # # free-php.net (http://free-php.net) unless # # otherwise stated in the module. # # # # Any copying, distribution, modification with # # intent to distribute as new code will result # # in immediate loss of your rights to use this # # program as well as possible legal action. # # # ######################################################### include('SignUp/questconfig.inc'); if ($_SERVER['REQUEST_METHOD'] == "POST") { $ContactName = $_POST[ContactName]; $CompanyName = $_POST[CompanyName]; $YourPosition = $_POST[YourPosition]; $ContactEmail = $_POST[ContactEmail]; $Service = $_POST[service]; $WebAddress = $_POST[WebAddress]; $ExistingSite = $_POST[ExistingSite]; $Maintainyoursite = $_POST[Maintainyoursite]; $Content = $_POST[Content]; $Images = $_POST[images]; $Logo = $_POST[Logo]; $WebsiteSize = $_POST[WebsiteSize]; $Competitor1Name = $_POST[Competitor1Name]; $Competitor1URL = $_POST[Competitor1URL]; $Competitor2Name = $_POST[Competitor2Name]; $Competitor2URL = $_POST[Competitor2URL]; $Competitor3Name = $_POST[Competitor3Name]; $Competitor3URL = $_POST[Competitor3URL]; $MainFunctions = $_POST[MainFunctions]; $References1 = $_POST[References1]; $References2 = $_POST[References2]; $References3 = $_POST[References3]; $BetterFeel = $_POST[betterFeel]; // $msg2 is set in config.inc which formats the body of the message mail("$adminemail[$who]", "$subjectheader $subject", "$msg2", "From: $email \nReply-To: $email"); if ($redirecturl != "") { header("Location: $redirecturl"); exit(); } else { echo "<br><center>$finishedtext</center><br>"; } } else { include($script_dir . '/header.php'); include($script_dir . '/questionare.php'); include($script_dir . '/footer.php'); } ?> the header / questionare / footer pages are here: <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title><? echo $scriptname; ?></title> <META name="description" content=""> <META name="keywords" content=""> <META name="revisit-after" content="7days"> <META name="robots" content="index, follow"> <link href="../../../NacStyles/Nacota.css" rel="stylesheet" type="text/css"> <SCRIPT LANGUAGE="JavaScript"> <!-- Hide code from non-js browsers function validate() { formObj = document.CustomerForm; if ((formObj.ContactName.value == "") || (formObj.CompanyName.value == "") || (formObj.YourPosition.value == "") || (formObj.ContactEmail.value == "")) { alert("You have not filled in all required fields."); return false; } else { header("Location: $redirecturl"); return true; } } function formReset() {document.getElementById("CustomerForm").reset()} // end hiding --> </SCRIPT> </HEAD> <body><center> <!-- Head --> <div id="head"></div> <!-- end Head --> <!-- Main --> <div id="main"> <form name="CustomerForm" method="post" id="CustomerForm" action="<? echo $script_url; ?>/signup.php" onsubmit="return validate()" > <table border="0" cellpadding="2" width="100%" class="main"> <tr> <td colspan="2" align="center" class="mainbold">Please fill out this questionaire as fully as possible, this will help us in creating your custom website!</td> </tr><!--headline--> <tr> <td align="right">Your name:</td> <td align="center"><input type="text" tabindex="1" size="20" name="ContactName" /></td> </tr><!--contact name--> <tr> <td align="right">The company name you represent:</td> <td align="center"><input type="text" tabindex="2" size="20" name="CompanyName" /></td> </tr><!--company name--> <tr> <td align="right">Your position in the company (Owner, CEO, etc.):</td> <td align="center"><input type="text" tabindex="3" size="20" name="YourPosition" /></td> </tr><!--position in company--> <tr> <td align="right">Your e-mail address:</td> <td align="center"><input type="text" tabindex="4" size="20" name="ContactEmail" /></td> </tr><!--contact e-mail--> <tr> <td align="right">Have you already purchased your domain name and hosting service?</td> <td align="center"><label for="domain">Domain:</label><input type="radio" tabindex="5" id="domain" name="Service" value="domain" /><br><label for="hosting">Hosting:</label><input type="radio" tabindex="6" id="hosting" name="Service" value="hosting" /><br><label for="both">Both:</label><input type="radio" tabindex="7" id="domainhosting" name="Service" value="both" /></td> </tr><!--Service--> <tr> <td align="right">What is the web site name(www.your-name.com)?</td> <td align="center"><input type="text" tabindex="8" id="webaddress" size="20" name="WebAddress" /></td> </tr><!--site address--> <tr> <td align="right">Do you currantly have an existing website?</td> <td align="center"><label for="existingsiteYes">Yes:</label><input type="radio" tabindex="9" id="existingsiteYes" name="ExistingSite" value="Yes" /><label for="existingsiteNo">No:</label><input type="radio" tabindex="10" id="existingsiteNo" name="ExistingSite" value="No" /></td> </tr><!--existing website--> <tr> <td align="right">Will you be using our services for maintenance, updates and upgrades?</td> <td align="center"><label for="maintainYes">Yes:</label><input type="radio" tabindex="11" id="maintainYes" name="Maintainyoursite" value="Yes" /><label for="maintainNo">No:</label><input type="radio" tabindex="12" id="maintainNo" name="Maintainyoursite" value="No" /></td> </tr><!--maintain--> <tr> <td align="right">Do you have content (text) for the website?</td> <td align="center"><label for="contentYes">Yes:</label><input type="radio" tabindex="13" id="contentYes" name="Content" value="Yes" /><label for="contentNo">No:</label><input type="radio" tabindex="14" id="contentNo" name="Content" value="No" /></td> </tr><!--content--> <tr> <td align="right">Do you have the images for the website?</td> <td align="center"><label for="imagesYes">Yes:</label><input type="radio" tabindex="15" id="imagesYes" name="Images" value="Yes" /><label for="imagesNo">No:</label><input type="radio" tabindex="16" id="imagesNo" name="Images" value="No" /></td> </tr><!--images--> <tr> <td align="right">Do you have an image of your logo for the website?</td> <td align="center"><label for="logoYes">Yes:</label><input type="radio" tabindex="15" id="logoYes" name="Logo" value="Yes" /><label for="logoNo">No:</label><input type="radio" tabindex="16" id="logoNo" name="Logo" value="No" /></td> </tr><!--logo--> <tr> <td align="right">How many pages do you expect the site to have? (rough idea)</td> <td align="center"><input type="text" tabindex="17" id="size" size="20" name="WebsiteSize" /></td> </tr><!--size--> <tr> <td align="right">Who are your company's closest competitors?</td> <td align="right"><label for="competitor1name">Company #1<br>Name:</label><input type="text" tabindex="18" size="20" id="competitor1name" name="Competitor1Name" /><br><label for="competitor1url">URL:</label><input type="text" tabindex="19" size="20" id="competitor1url" name="Competitor1URL" /><br> <label for="competitor2name">Company #2<br>Name:</label><input type="text" tabindex="20" size="20" id="competitor2name" name="Competitor2Name" /><br><label for="competitor2url">URL:</label><input type="text" tabindex="21" size="20" id="competitor2url" name="Competitor2URL" /><br> <label for="competitor3name">Company #3<br>Name:</label><input type="text" tabindex="22" size="20" id="competitor3name" name="Competitor3Name" /><br><label for="competitor3url">URL:</label><input type="text" tabindex="23" size="20" id="competitor3url" name="Competitor3URL" /></td> </tr><!--competitors--> <tr> <td align="right">What would you like your website to do for you?</td> <td><textarea id="functions" rows="4" cols="30" tabindex="24" name="MainFunctions"></textarea></td> </tr><!--functions--> <tr> <td align="right">Are there any websites you'd like us to view for style references?</td> <td align="right"><label for="reference1">URL #1:</label><input type="text" id="reference1" tabindex="25" name="References1" size="20" /><br> <label for="reference2">URL #2:</label><input type="text" id="reference2" tabindex="26" name="References2" size="20" /><br> <label for="reference3">URL #3:</label><input type="text" id="reference3" tabindex="27" name="References3" size="20" /></td> </tr><!--references--> <tr> <td align="right">Is there anything else you'd like to include that might help give us a better 'feel' for your web project, or have any comments that don't fit above?</td> <td><textarea id="betterfeel" rows="4" cols="30" tabindex="28" name="BetterFeel"></textarea></td> </tr><!--better Idea--> <tr> <td align="right"></td> <td></td> </tr><!--blank--> <tr> <td></td> <td align="right"><input class="button" type="reset" value="Clear" /><input class="button" type="submit" value="Submit" /></td> </tr><!--submit buttons--> </table> </form> </div> <!-- end Main --> <BR><BR><!--{placeholder for footer html here}--></center> <BR> <BR> </BODY> </HTML> also connected is the config.inc now if my server dosent support .inc can it be changed to .php (and just make the changes on the other pages)?? here is the code in it <? ######################################################### # ContactForm # ######################################################### # # # Created by: Doni Ronquillo # # Modified by: CodeMunkyX # # # # This script and all included functions, images, # # and documentation are copyright 2003 # # free-php.net (http://free-php.net) unless # # otherwise stated in the module. # # # # Any copying, distribution, modification with # # intent to distribute as new code will result # # in immediate loss of your rights to use this # # program as well as possible legal action. # # # ######################################################### # script name $scriptname = "CustomerForm"; # use full paths # not using full paths could prevent the script from functioning properly # script directory # no trailing slash $script_dir = "/home/a8420943/public_html/html/mailforms/SignUp"; # script url (url to script directory above) # no trailing slash $script_url = "http://www.nacota.comlu.com/html/mailforms/SignUp"; # variables below corresponds to the Email to * in your contact form # match the numbers to the value for which option maps to a specific email # you can add more as long as you keep them in sync $adminemail = "[email protected]"; # preceeds the subject the user puts in on the contact form $subjectheader = "[Customer Sign~Up Form]:"; # url the form will redirect to after sending email $redirecturl = "http://www.nacota.comlu.com"; # text that will display if you leave above variable blank $finishedtext = "Thank you for your interest, We will be contacting you soon!"; # how the message will show in the email # you can reorder these how you wish or modify the message itself to your liking # just be sure and leave the $variables in tact $msg2 = " Name: $ContactName Company: $CompanyName Position: $YourPosition Email: $ContactEmail Service: $Service Web Site Address: $WebAddress Existing Site: $ExistingSite Maintain your site: $Maintainyoursite Content Provided: $Content Images Provided: $Images Logo Provided: $Logo Progeted Website Size: $WebsiteSize Competitor1Name: $Competitor1Name Competitor1URL: $Competitor1URL Competitor2Name: $Competitor2Name Competitor2URL: $Competitor2URL Competitor3Name: $Competitor3Name Competitor3URL: $Competitor3URL Main Functions for site: $MainFunctions References1: $References1 References2: $References2 References3: $References3 Get a better feel: $BetterFeel "; ?> this code just isnt moving past the "submit" button its no longer giving me a error (excluding the notices explained above) its just going to the webservers error page with out anything happening Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927323 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 As far as I can tell the problems you are having must revolve around the JavaScript section. <SCRIPT LANGUAGE="JavaScript"> <!-- Hide code from non-js browsers function validate() { formObj = document.CustomerForm; if ((formObj.ContactName.value == "") || (formObj.CompanyName.value == "") || (formObj.YourPosition.value == "") || (formObj.ContactEmail.value == "")) { alert("You have not filled in all required fields."); return false; } else { header("Location: $redirecturl"); return true; } } function formReset() {document.getElementById("CustomerForm").reset()} // end hiding --> </SCRIPT> As this code is ran when you submit the form, if you have filled in the 4 required fields it will attempt to run the line... header("Location: $redirecturl"); To my knowledge that is not valid JavaScript code and that line shouldn't be there at all. Once I removed that, the script seemed to 'move on'. Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927330 Share on other sites More sharing options...
Nacota Posted September 29, 2009 Author Share Posted September 29, 2009 well I dont know dosent seem to want to work you can visit here if you want to take a look at what is happening http://www.nacota.comlu.com/html/mailforms/signup.php also for ease of working only the top 4 textbox's validate and as long as theres a @ in the email anything will pass in the others it just dies dont know I dont get anything Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927343 Share on other sites More sharing options...
Nacota Posted September 30, 2009 Author Share Posted September 30, 2009 Bump.. still having an issue with this anyone have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/175973-need-some-redirect-help/#findComment-927724 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.