Jump to content

Help with header and $_POST


atrum

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'] != "")

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.