EdoDodo Posted July 1, 2007 Share Posted July 1, 2007 Hi. I know how to make forms and how to take them and echo them and stuff but when I try to set the to variables it doesn't seem to work. Can anyone help me please? Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/ Share on other sites More sharing options...
bluebyyou Posted July 1, 2007 Share Posted July 1, 2007 Post your code please. Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287082 Share on other sites More sharing options...
mmarif4u Posted July 1, 2007 Share Posted July 1, 2007 Yes post ur code that we may help u. Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287084 Share on other sites More sharing options...
EdoDodo Posted July 1, 2007 Author Share Posted July 1, 2007 Page 1: <form method="post" action="http://localhost/page2.php"> Minimum Number: <input type="text" size="10" maxlength="40" name="min_num"><br> Maximum Number: <input type="text" size="10" maxlength="10" name="max_num"><br> Number of Guesses: <input type="text" size="10" maxlength="10" name="guesses"><br> <input type="submit" value="Go!"> </form> Page 2: <?php $min_num='$_POST['min_num']'; $max_num='$_POST['max_num']'; $guesses='$_POST['guesses']'; echo '$min_num, $max_num, $guesses'; ?> I'm pretty sure it's just a silly mistaker but I'm new to PHP and stuff so I can't spot it. Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287086 Share on other sites More sharing options...
bluebyyou Posted July 1, 2007 Share Posted July 1, 2007 You dont need the single quotes. With the single quotes you are puting the $_POST variables in as strings. $min_num=$_POST['min_num']; $max_num=$_POST['max_num']; $guesses=$_POST['guesses']; Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287087 Share on other sites More sharing options...
EdoDodo Posted July 1, 2007 Author Share Posted July 1, 2007 I tried that and it doesn't give me the T-String error thing but it doesn't echo the variables just returns like: $min_num, $max_num, $guesses Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287088 Share on other sites More sharing options...
mmarif4u Posted July 1, 2007 Share Posted July 1, 2007 bcoz u r escaping it. try this: echo $min_num.$max_num.$guesses; Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287089 Share on other sites More sharing options...
trq Posted July 1, 2007 Share Posted July 1, 2007 <?php <?php $min_num=$_POST['min_num']; $max_num=$_POST['max_num']; $guesses=$_POST['guesses']; echo $min_num, $max_num, $guesses; ?> Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287091 Share on other sites More sharing options...
bluebyyou Posted July 1, 2007 Share Posted July 1, 2007 try this: echo $min_num, $max_num, $guesses; The single quote for a strings means echo litteraly what is inside, even if it is a variable name. read up on it here: http://www.php.net/types.string Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287092 Share on other sites More sharing options...
rameshfaj Posted July 1, 2007 Share Posted July 1, 2007 Yes probably ! there was a blunder to use such single quotations outiside the post function. Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287094 Share on other sites More sharing options...
bluebyyou Posted July 1, 2007 Share Posted July 1, 2007 you dont have to rub it in Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287096 Share on other sites More sharing options...
EdoDodo Posted July 1, 2007 Author Share Posted July 1, 2007 Solved! Thanks guys! Link to comment https://forums.phpfreaks.com/topic/57936-solved-forms-to-variables/#findComment-287133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.