First of all, will this code work in a .php document? <form method="POST" action="process.php"> <input type="text" name="address" size="20"> <input type="submit" value="Submit" name="submit"><br> <font face="Tahoma" size="1">Click SUBMIT to submit your information</font> </form> Code (markup): If so: How do I make it, so that when the visitors click the "Submit" button, they get redirected to a DIFFERENT PHP document? (this all has to be done in PHP, no HTML...long story). If that is impossible, is there any way I could make all that area change into a "Thank You" message or something? Again, all this has to be done in a .PHP document. The reason all this has to be in .php, is because this is going to be used in an application I'm developing, and the site that will use the application is the one that will be hosting it... not me. I don't have any webhosting, and the application host can't host a .html file... so I can't redirect to an html file. Thanks alot in advance guys <3 Sorry for the stupid question
Yes, it can be done in php/JS look for innerHTML. you can have in a .php file any type of code like: <script type="text/javascript"> function changeText(){ document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText()' value='Change Text'/> PHP:
<?php if(isset($_POST['submit'])) { //process submission code... echo "Thank You"; }else { ?> <form method="POST" action="process.php"> <input type="text" name="address" size="20"> <input type="submit" value="Submit" name="submit"><br> <font face="Tahoma" size="1">Click SUBMIT to submit your information</font> </form> <?php } ?> Code (markup):
You can't print a message "Thank you." and then redirect it..... If you set a action and then on submit button click you write 'thankyou' ..,But without write anything page automatic redirected...!! and in PHP code if you echo "Thankyou" and then redirect it using php code then error is ocured...so without printing you have to redirected it.. or other wise you have to use any delay code.. But without printing "Thank You" ...the code is.. <?php if(isset($_POST['submit']) { header("location: process.php"); } ?> <form method="POST"> <input type="text" name="address" size="20"> <input type="submit" value="Submit" name="submit"><br> <font face="Tahoma" size="1">Click SUBMIT to submit your information</font> </form>
or you can used refresh method: <?php if(isset($_POST['submit']){ print '<meta http-equiv="refresh" content="0;URL=pagename.php" />'; exit; } ?>
So if I add this code to AdnanAhsan's code, after they click submit, they'll be redirected to the pagename.php? This will have to come INSTEAD of the "Thank You" thingy right? Thanks alot guys you're really helping me out! and you all have great answers!
lol mate i wrote code just to echo thankyou, and not to redirect ... He can also print Thankyou and below new form .. just add form below echo line
Okay <?php header("Location: http://www.url.com"); ?> This will redirect to the right page. You might also want to try the "sleep()" function