Delacourt
asked on
PHP variables in form submitted to a new window, $_POST single quotes or double quotes
Hello Experts
I have a form that posts information to another page which is in a new window and I was wondering whether I should be using double quotes or single quotes in that next page
ie.
$var = $_POST['var'];
OR
$var = $_POST["var"];
what is the difference between using either and why does my page that the form is submitted to in the new window sometimes not show the variables ? mostly the first time I submit the form, click back and do it again and it works fine ?
Currently I am using double quotes
Thanks in Advance
I have a form that posts information to another page which is in a new window and I was wondering whether I should be using double quotes or single quotes in that next page
ie.
$var = $_POST['var'];
OR
$var = $_POST["var"];
what is the difference between using either and why does my page that the form is submitted to in the new window sometimes not show the variables ? mostly the first time I submit the form, click back and do it again and it works fine ?
Currently I am using double quotes
Thanks in Advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Of course I mean 'Variables' not 'Viables' just to be clear.
ASKER
Thanks so far, this is the code I have
//page that sends the form
<form action="prov_email.php" method="POST" target="_blank">
<?
print "<input type=\"hidden\" name=\"res_number\" value=\"$res_number\">";
print "<input type=\"hidden\" name=\"res_name\" value=\"$res_name\">";
print "<input type=\"hidden\" name=\"res_arrive\" value=\"$res_arrive\">";
print "<input type=\"hidden\" name=\"res_depart\" value=\"$res_depart\">";
print "<input type=\"hidden\" name=\"res_apt\" value=\"$res_apt\">";
print "<input type=\"hidden\" name=\"res_rate\" value=\"$res_rate\">";
print "<input type=\"hidden\" name=\"res_vl_agent\" value=\"$res_vl_agent\">";
?>
<p><input type="submit" value="Send Provisional Email in New Window" /></p>
</form>
//prov_email.php page form is being sent to
<?
//dbconnection
include"serv.inc";
error_reporting(0);
$res_number = $_POST["res_number"];
$res_name = $_POST["res_name"];
$res_arrive = $_POST["res_arrive"];
$res_depart = $_POST["res_depart"];
$res_apt = $_POST["res_apt"];
$res_rate = $_POST["res_rate"];
print "$res_number : res_number var<br />";
//the above does not always print the variable the first time, most times afterwards it does though ?
In your initial page, where do you get the variables from?
Also, when experiencing problems with your code, you could add error_reporting(E_ALL) to the top of both your files.
Kind regards,
Matthias Vance
Also, when experiencing problems with your code, you could add error_reporting(E_ALL) to the top of both your files.
Kind regards,
Matthias Vance
On your first page, do all the values appear correctly when you view page source?
ASKER
variables are received from another form (built in the exact same way except not sent to a new window and it works every time no problem)
values are always there and are correct
register globals are set to on - if this helps, i know the code doesnt need it on though
values are always there and are correct
register globals are set to on - if this helps, i know the code doesnt need it on though
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow, ok need to read that again - thanks so far - out of interest is there a way to do it without sessions ?
Yes, you can append them to your query string (ie. index.php?key1=value&key2= value) and then retrieve them with $_GET['key1'] etc.
Kind regards,
Matthias Vance
Kind regards,
Matthias Vance
On your first page just try first naming each variable and giving it a value of nothing above your form then as long as the session is going and the variable is registered then on the second page it will display because it is now set up and exists in the session. ;)
then to print on the test page just say:
echo("$_POST[res_number]") ;
or
foreach($_POST as $key => $var) {
echo("$key = $var<br>");
}
Then you can check every posted variable. Then in your code to say save everything just refer to the variables as $_POST[your_posted_variabl e]
echo("$_POST[res_number]")
or
foreach($_POST as $key => $var) {
echo("$key = $var<br>");
}
Then you can check every posted variable. Then in your code to say save everything just refer to the variables as $_POST[your_posted_variabl