Forums
This topic is locked
pass a form variable in DWMX2004 w/ PHP
18 Jan 2005 20:38:07 phil cady posted:
howdy, i'm having a problem passing a form variable in PHP. ok my page works great, i am inserting a new record in my MySQL db and then i am sending the user to a confirmation page. i want to display their new confirmation code. it will work if i manually put the variable into my URL string. for example: /reservations_add_ride.php?sid=6223&NumAdults=1&NumChildren=0
and i need to add one more variable, called 'rid'.
this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?>
however i get nothing when i try that... no error either. but if i manually insert the variable in my URL thusly:
/reservations_add_ride.php?sid=6223&NumAdults=1&NumChildren=0&rid=14677
the confirmation page works just fine! so i know its just a matter of trapping and passing that info to the confirmation page properly.
any help would be greatly appreciated!
Replies
Replied 18 Jan 2005 20:58:13
18 Jan 2005 20:58:13 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
Replied 18 Jan 2005 21:09:38
18 Jan 2005 21:09:38 phil cady replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
oh, that's excellent! thanks! ok, ummmmm now i just need to pass that info to my confirmation page. how do i append that new variable to my URL string?
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
oh, that's excellent! thanks! ok, ummmmm now i just need to pass that info to my confirmation page. how do i append that new variable to my URL string?
Replied 18 Jan 2005 21:47:37
18 Jan 2005 21:47:37 phil cady replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
oh, that's excellent! thanks! ok, ummmmm now i just need to pass that info to my confirmation page. how do i append that new variable to my URL string?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
ok, got it. hehehe, basically just RTFM. =]
i just incorporated the mysql_insert_id() function into my query on the confirmation page and it worked just peachy.
thanks!
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>...this variable is the new id created from the insert into the db. so i was trying to trap the value by doing this:
<pre id=code><font face=courier size=2 id=code><?php
$sql = "select LAST_INSERT_ID() from rides";
$my_rid = mysql_query($sql);
echo $_POST['rid']; ?></font id=code></pre id=code>
...<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
That code shows you are trying to get it from MySQL iteself; PHP has it's own way, and works very well: us3.php.net/manual/en/function.mysql-insert-id.php
Just throw that PHP last id function right after, and should work out-of-the-box.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
oh, that's excellent! thanks! ok, ummmmm now i just need to pass that info to my confirmation page. how do i append that new variable to my URL string?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
ok, got it. hehehe, basically just RTFM. =]
i just incorporated the mysql_insert_id() function into my query on the confirmation page and it worked just peachy.
thanks!
Replied 18 Jan 2005 21:50:48
18 Jan 2005 21:50:48 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>ok, got it. hehehe, basically just RTFM. =]
i just incorporated the mysql_insert_id() function into my query on the confirmation page and it worked just peachy.
thanks!<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Awesome, you're welcome. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
i just incorporated the mysql_insert_id() function into my query on the confirmation page and it worked just peachy.
thanks!<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Awesome, you're welcome. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>