ali_2kool2002 Posted February 20, 2007 Share Posted February 20, 2007 Hey guys,,, im using java script in php. The problem is i have a form which has a submit button it transfers to the handling form script page but i want to keep it on the same page? is it anything to do with this line ? <form name="myForm" action="addtocart.php" method="post"> and if i do keep on the same page would that mean i would need to transfer the handling code in my file named "addtocart.php" to the 1st page? Quote Link to comment Share on other sites More sharing options...
craygo Posted February 20, 2007 Share Posted February 20, 2007 Yes. If you want everything done on one page, you would put all your code on one page and add a check to see if the form has been submitted. <?php if(isset($_POST['submit'])){ // Code to process your form below } else { // code to show your form below echo "<form name=\"myForm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; } ?> Ray Quote Link to comment Share on other sites More sharing options...
lando Posted February 20, 2007 Share Posted February 20, 2007 Nevermind, someone beat me to the post Quote Link to comment Share on other sites More sharing options...
skali Posted February 20, 2007 Share Posted February 20, 2007 If you don't want to transfer your Post handling code to the first file then you can also include the other file in your first file: if($_SERVER['REQUEST_MOTHOD']=='POST'){ include 'post_handling_file'; } Quote Link to comment Share on other sites More sharing options...
ali_2kool2002 Posted February 20, 2007 Author Share Posted February 20, 2007 cheers ppl....ur all 2 kool for me! :-* Quote Link to comment 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.