gniterobot Posted November 24, 2006 Share Posted November 24, 2006 Hi, I am essentially trying to create a page where this would work...<?$name = $_POST['name'];if($_POST['_submit_check']){print $name;}?>....<form action="<?=$_SERVER['PHP_SELF'];?>" method="post"> NAME: <input name="name" type="text" /> <input type ="hidden" name="_submit_check" value="1" /><input type="submit" />The problem seems to be that it works once, then defaults every time after to not recognizing the name.So you could imagine the first time a user sees a form, he types "Mike" and hits submit. then he sees MIKE and the form. then if he type "Susy" and hits submit it SHOULD say Susy and print the form, but it doesn't. How do I make it so the same page can be submitted to time and time again?Thanks in advance!-Matt Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/ Share on other sites More sharing options...
Ninjakreborn Posted November 24, 2006 Share Posted November 24, 2006 if($_POST['_submit_check'] == 1) Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-129721 Share on other sites More sharing options...
kenrbnsn Posted November 24, 2006 Share Posted November 24, 2006 Instead of having the hidden field, give the submit button a name and check for that:[code]<?phpif (isset($_POST['submit'])) echo 'Name: ' . $_POST['name'] . '<br>';?><form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">NAME: <input name="name" type="text" /><input type="submit" name="submit" /></form>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-129722 Share on other sites More sharing options...
saeed_violinist Posted November 24, 2006 Share Posted November 24, 2006 Also I found this articles useful, may help :http://www.thesitewizard.com/archive/phptutorial1.shtmlhttp://www.thesitewizard.com/archive/phptutorial2.shtml Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-129725 Share on other sites More sharing options...
gniterobot Posted November 25, 2006 Author Share Posted November 25, 2006 [quote author=businessman332211 link=topic=116185.msg473231#msg473231 date=1164399142]if($_POST['_submit_check'] == 1)[/quote]This isn't quite my problem. The problem is that it works the first time, then the next time they try to use the form it won't use the updated name.I cn verify that the first time the enter the page no name is printed, that is fine. But how can I make it so the page can be used over and over? Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130179 Share on other sites More sharing options...
.josh Posted November 25, 2006 Share Posted November 25, 2006 perhaps you should be more clear in your explanation. Are you wanting a variable to persist each time someone is clicking submit? Are you looking to do something like make a session variable? Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130180 Share on other sites More sharing options...
gniterobot Posted November 25, 2006 Author Share Posted November 25, 2006 My original post explains it best...So from that sample code you should be able to navigate to the page and the first time the form is printed but no name (obviously).The person types in their name and hits submit, now their name is printed followed by the form. They then type a NEW name and click submit. It SHOULD print the new name and the form. But instead it only prints the form and no name, as if it was the first time they went to the page.It's a simplier version of the problem I having, but they are identical is nature. How can I make it so every time the submit the page updates with the new information??Ok it appears it's a time issue.So if I wait 5 minutes or so and resubmit it works, but if I type a new name and resubmit right away it returns to the default screen..Anyway around this? Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130181 Share on other sites More sharing options...
gniterobot Posted November 25, 2006 Author Share Posted November 25, 2006 Ok, So it takes 15 seconds before I can submit the form again and have it use the new post data.Where is this restriction imposed?Can I get around it? Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130189 Share on other sites More sharing options...
ataria Posted November 25, 2006 Share Posted November 25, 2006 I dooo.if (!$page) {// if no action is taken. }if ($page == something){// actions} Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130202 Share on other sites More sharing options...
mainewoods Posted November 26, 2006 Share Posted November 26, 2006 write the $name field into the form field after you get it:[code]<input name="name" type="text" value="<?php echo $name; ?>" />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/28361-submitting-a-form-to-the-same-page-help/#findComment-130314 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.