atrum Posted April 7, 2008 Share Posted April 7, 2008 Hey guys, I am pretty new to php, and need some help with a script. basically I am trying to create a script that will insert data into a premade url search query. Here is the code, that I am having issues with. <?php if ($_POST['first'] == !"" && $_POST['date1'] == !"" && $_POST['date2'] == !"") { header( 'Location: https://ids03.team-center.net/IDS/Data/ActivityMgr/activity_summary?tag_status%3Austring%3Autf8 =Status&tag_product%3Austring%3Autf8=Product&tag_about%3Austring%3Autf8=0000+About+Anything&tag_type%3Austring%3Au tf8=Type&tag_team%3Austring%3Autf8=IDS_Teams&tag_source%3Austring%3Autf8=Source&root%3Austring%3Autf8=Actions&for_ user%3Austring%3Autf8=' . $_POST['userid'] . '&tag_role%3Austring%3Autf8=work_done&date_restrict%3Austring%3Autf8=wor k_done&date_from%3Austring%3Autf8=' . $_POST['date1'] . '&date_to%3Austring%3Autf8=' . $_POST['date2'] . '&selected=11 53'); } else { echo "<h1><b>Please go back and fill out the form completely!</b></h1>"; } ?> <html> <head> <title>Email Tracker</title> </head> <body> <?php $date1 = (date("m%2fd%2fY")); $date2 = (date("m%2fd%2fY")); ?> <form name="email" action="test2.php" method="post"> <input type="text" name="userid" /> <input type="hidden" name="$date1" /> <input type="hidden" name="$date2" /> <input type="submit" name="Submit" /> </form> </body> </html> The issue I am having with this is that when I fill out the form and submit the script, it just produces a blank page, and the header doesnt get written to the addressbar. any help any one can give would be appreciated. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 7, 2008 Share Posted April 7, 2008 A blank page usually means you have errors but also have the display_errors() setting turned off. Adding this line: ini_set('display_errors','On'); To the top of your script should show you the relevant error. I would suspect it will be a notice telling that that $_POST['first'] is undefined. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 7, 2008 Share Posted April 7, 2008 The following line has incorrect syntax: if ($_POST['first'] == !"" && $_POST['date1'] == !"" && $_POST['date2'] == !"") you should use != rather than == ! Also you dont have a field called first in your form. I believe you meant $_POST['userid'] rather than $_POST['first']. Corrected code: if ($_POST['userid'] != "" && $_POST['date1'] != "" && $_POST['date2'] != "") Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 The following line has incorrect syntax: if ($_POST['first'] == !"" && $_POST['date1'] == !"" && $_POST['date2'] == !"") you should use != rather than == ! You know, when i saw that i thought it would throw a syntax error. But i thought i'd just try it first, since it does make reasonable sense - turns out it works fine. Never seen anybody use that syntax before. Quote Link to comment Share on other sites More sharing options...
ramchel Posted April 8, 2008 Share Posted April 8, 2008 Hi, it seems nothing wrong in your tes2.php. but there are few things you need to correct in your form file. first you need to change the name of the hidden date fields. i assume you are not trying to create dynamic hidden field names and you instead of assigning something to 'value' property you ended up assigning to 'name' property. Your problem is more of HTML rather than PHP. so change the HTML code as follows Actual Code: <input type="text" name="userid" /> <input type="hidden" name="$date1" /> <input type="hidden" name="$date2" /> Change To: <input type="text" name="first" value=""/> <input type="hidden" name="date1" value="<?=$date1?>" /> <input type="hidden" name="date2" value="<?=$date2?>" /> Hope this give you helpful info. "Happy Coding" Ramchel 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.