cleverlyslick Posted September 25, 2009 Share Posted September 25, 2009 Hello folks! as I stated in my previous post I am a php newb and trying to learn slowly but surely. I'm creating a simple forms page and having trouble getting the output. here is the code.... <form id="form1" name="form1" method="post" action=""> <label for="textfield">credit score:</label> <input type="text" name="creditscore" id="creditscore" /> <p> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="go" /> </p> </form> That's for the first page... <?php $creditscore = $_POST['creditscore']; echo "{creditscore}:"; ?> what i'm trying to do is have user enter their number in the box,click go and retrieve the result in the next page. when I test it to see if it works,it just shows the forms page again. can someone tell me what i'm doing wrong and how can I fix the problem? Again I only been playing with php for 2 weeks now so i'm still trying to learn. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/ Share on other sites More sharing options...
mikesta707 Posted September 25, 2009 Share Posted September 25, 2009 echo $creditscore; you only need to surround arrays with curly brackets in strings Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924903 Share on other sites More sharing options...
cleverlyslick Posted September 25, 2009 Author Share Posted September 25, 2009 removed the curly braces,but still having same issues any other suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924919 Share on other sites More sharing options...
mikesta707 Posted September 25, 2009 Share Posted September 25, 2009 post what you have. if you have the following $creditscore = $_POST['creditscore']; echo $creditscore; then it will do what you want it to. I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like <form id="form1" name="form1" method="post" action="page.php"><?php //Right here is what i changed ?> <label for="textfield">credit score:</label> <input type="text" name="creditscore" id="creditscore" /> <p> <label for="submit"></label> <input type="submit" name="submit" id="submit" value="go" /> </p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924926 Share on other sites More sharing options...
cleverlyslick Posted September 25, 2009 Author Share Posted September 25, 2009 I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like THIS! Thanks a lot for your help Mike.Problem is solved! I use dreamweaver to make the form for me and completely forgot to enter where the action is going.very much appreciated. Hope to become an expert like you guys soon! Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924935 Share on other sites More sharing options...
eatfishy Posted September 25, 2009 Share Posted September 25, 2009 If you would like the value to be pass onto the next page, you can use session variable for that. Ex: $_SESSION['name']=$_POST['name']; Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924937 Share on other sites More sharing options...
cleverlyslick Posted September 25, 2009 Author Share Posted September 25, 2009 If you would like the value to be pass onto the next page, you can use session variable for that. Ex: $_SESSION['name']=$_POST['name']; tried it out and worked also! thanks guys.very helpful.you'll be hearing from a lot in this forum lol so brace yourselves. Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924952 Share on other sites More sharing options...
TeNDoLLA Posted September 25, 2009 Share Posted September 25, 2009 I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like THIS! Thanks a lot for your help Mike.Problem is solved! I use dreamweaver to make the form for me and completely forgot to enter where the action is going.very much appreciated. Hope to become an expert like you guys soon! No offence or anything like that. But if you really want to learn better, I suggest you get rid of DW. Start cofing with some decent editor that has php syntax highlighting and start doing some small projects bit by bit and making sure that you understand always every part that you write. Then when feeling comfortable set some little harder/bigger goals. I really don't think that DW is very good way to learn coding. Also it generates poor code. Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924969 Share on other sites More sharing options...
mikesta707 Posted September 25, 2009 Share Posted September 25, 2009 I use dreamweaver for coding PHP, and I always have. It has php syntax highlighting and all that jazz. However, you are right when you say it generates bad code. It generates craptastic code, but as long as you are hand writing all your code then you will be fine. Dreamweaver is still on of my favorite IDE's, for web development anyways Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-924997 Share on other sites More sharing options...
eatfishy Posted September 25, 2009 Share Posted September 25, 2009 NetBean is another choice for PHP IDE, but not sure if it's as good as dreamweaver. Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-925004 Share on other sites More sharing options...
mikesta707 Posted September 25, 2009 Share Posted September 25, 2009 I personally hate netbeans with a passion. But I used it for Java, and it was really slow, and would lock up alot. Eclipse is 20 times better than newbeans in my opinion. Never used it for PHP though. Quote Link to comment https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/#findComment-925011 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.