php post to another page or the same? -


i create page php posts this:

page1.php:

<form action="page2.php" method="post"> ... </form> 

page2.php:

<?php $var = $_post['...']; ?> 

one friend of mine told me should in same page: page1.php

<?php if (isset($_post['...'])){ ... } else{ ?>    <form action="page1.php" method="post">     ...     </form> <?php } ?> 

my question is, 1 better or faster method , best practise? thank friends!

you can in both ways have mentioned .

its not "should in same page"

in first part passing control page1 page2 ...which done submit button can directly values using $_post['...'];

now in seccond part passing control same page , since calling same page on submit .

but here need check if post data has been set use isset method. most importantly can use second solution if want stay on same page after submission

therefore, use of isset() method in first part good habbit , in second solution necessity

in opinion better use page code not messed up.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -