abdfahim Posted July 8, 2007 Share Posted July 8, 2007 let this is the code for page1.php <?php $postid=$_GET['id']; $user=$_SESSION['sess_username']; $poster=$_GET['user']; if(isset($_POST['edit'])){ if($user==$poster){ $new_posted=$_POST['edit_msg']; mysql_query("UPDATE posts SET posts='$new_posted' WHERE id='$postid'"); } exit(); } ?> <html><body> <form action="" method="post" name="editpost"> <table> <tr> <td> <textarea name="edit_msg" cols="62" rows="8"> <?php $pr_post=mysql_query("SELECT posts FROM posts WHERE id='$postid'"); $pr_pt=mysql_result($pr_post,0,"posts"); echo $pr_pt; ?> </textarea> </td> </tr> <tr class> <td><input type="submit" name="edit" value="Submit" class="btn"></td> </tr> </table> </form> Here I put form action blank, and he above code works fine. But if I put <from action="page1.php"> in the above code, the code does not work beacuse the value of php variables $postid, $poster etc is not hold after I click on submit button. Is there any logic behind this?? Link to comment https://forums.phpfreaks.com/topic/58927-empty-action-in-form/ Share on other sites More sharing options...
MemphiS Posted July 8, 2007 Share Posted July 8, 2007 try this form <form action="page1.php" method="post"> Link to comment https://forums.phpfreaks.com/topic/58927-empty-action-in-form/#findComment-292422 Share on other sites More sharing options...
abdfahim Posted July 8, 2007 Author Share Posted July 8, 2007 well i meant this. like <form action="" method="post" name="editpost"> instead Link to comment https://forums.phpfreaks.com/topic/58927-empty-action-in-form/#findComment-292423 Share on other sites More sharing options...
Yesideez Posted July 8, 2007 Share Posted July 8, 2007 If you have an empty action then it'll use the current script. You need to specify the method as this tells PHP how to send the data in the form. GET appends teh form data onto the URL (read using $_GET) POST sends the data in a packet instead (read using $_POST) Link to comment https://forums.phpfreaks.com/topic/58927-empty-action-in-form/#findComment-292426 Share on other sites More sharing options...
abdfahim Posted July 9, 2007 Author Share Posted July 9, 2007 If you have an empty action then it'll use the current script. You need to specify the method as this tells PHP how to send the data in the form. GET appends teh form data onto the URL (read using $_GET) POST sends the data in a packet instead (read using $_POST) Yup I know what method is for. Actually I am not facing any problem. Just for curiosity, I want to know what an empty action mean. Do you please explain me what did you mean by " it'll use the current script". Link to comment https://forums.phpfreaks.com/topic/58927-empty-action-in-form/#findComment-293147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.