sniped22 Posted May 27, 2007 Share Posted May 27, 2007 <html> <body> <?php $db_host = "XXXXXXX"; $db_user = "XXXXX"; $db_pass = "XXXXX"; $db_name = "XXXXX"; class db { function connect($db_host, $db_user, $db_pass, $db_name) { mysql_connect($db_host, $db_user, $db_pass); mysql_select_db("$db_name") or die(mysql_error()); } function query($query) { $query = mysql_query($query) or die(mysql_error()); return $query; } function fetch_array($query) { $query = mysql_fetch_array($query); return $query; } function fetch_row($query) { $query = mysql_fetch_row($query); return $query; } function close() { mysql_close(); } } $myDb=new db; $myDb->connect($db_host, $db_user, $db_pass, $db_name); $myDb->query("INSERT into poker(link) VALUES('$link');"); function createRandomUrl() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 15) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } $link = CreateRandomUrl(); echo "<form name='name' action='viewhand.php?link=$link' method='post'> <TEXTAREA Rows =30 Cols = 75 NAME = 'pokerhand'> Your Pokerhand Here </TEXTAREA></br> <input type='submit' value='submit'>" ?> </body> </html> I need to POST the textarea, but GET the link variable in the URL. Or how can i make it so when you press submit you are redirected to (action=view.php?link=1234)? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/ Share on other sites More sharing options...
Barand Posted May 27, 2007 Share Posted May 27, 2007 I personally hate mixes of get and post. I'd put the link value in a hidden form field and then just use post. <input type='hidden' name='link' value='1234'> Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262515 Share on other sites More sharing options...
sniped22 Posted May 27, 2007 Author Share Posted May 27, 2007 but i need the 'link' variable to be in the URL so that people can go to 'view.php?link=XXXX' where XXXX = a random number created on the POSTing page. Any help? Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262681 Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 i don't see the problem with the way your doing it ? action='viewhand.php?link=$link' should be fine and pokerhand should be posted! Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262686 Share on other sites More sharing options...
sniped22 Posted May 27, 2007 Author Share Posted May 27, 2007 when i submit the first page it doesn't redirect to viewhand.php?link='$link', it posts to viewhand.php without any GET variable. Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262692 Share on other sites More sharing options...
chocopi Posted May 27, 2007 Share Posted May 27, 2007 Thats because in your form tag the method is set to post and not get so: echo "<form name='name' action='viewhand.php?link=$link' method='post'> should be echo "<form name='name' action='viewhand.php?link=$link' method='get'> ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262694 Share on other sites More sharing options...
Diego17 Posted May 27, 2007 Share Posted May 27, 2007 no, that's all right. you can mix post and get. I guess $link is empty. echo "<form name='name' action='viewhand.php?link=$link' method='post'> value of link is: $link <br /> Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262695 Share on other sites More sharing options...
sniped22 Posted May 27, 2007 Author Share Posted May 27, 2007 I'm really dumb. My server's index page is index.html and the file i was using was index.php so I just went to my website's main page and stuff that I changed wasn't working... silly me! Quote Link to comment https://forums.phpfreaks.com/topic/53136-solved-get-and-post/#findComment-262706 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.