Jump to content

Empty Action in Form


abdfahim

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.