Error in Post Index

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

sashmaira
New php-forum User
New php-forum User
Posts: 2
Joined: Thu Jan 19, 2012 10:46 pm

Error in Post Index

Postby sashmaira » Thu Jan 19, 2012 11:11 pm

<html>

<form action = "<?=$_SERVER['php_self']?>" method = "POST">
Message:<input type = "text" name = "msg">
<input type = "submit" value = "send" name = "submit">
</form>

<?php !
$input = $_POST['msg'];
echo "$input";
?>
</html>

rupali
New php-forum User
New php-forum User
Posts: 140
Joined: Thu Oct 13, 2011 10:32 pm
Location: Chandigarh, INDIA

Re: Error in Post Index

Postby rupali » Fri Jan 20, 2012 1:44 am

hello,

error is in php_self , as its a declared request for server, so its mandatory or its a rule that it should be declared in upper case. so the correct one is

$_SERVER['PHP_SELF']

and one more thing, i advice you to mention this code
<?php
if(isset($_POST['submit'])) //submit is the name of submit button as declared in your script
{
//Code
}
?>

because if this code is not mentioned and you are trying to execute two codes in a single page, then undefined index : `variable name` error is shown.
so this is just only my advice !!!


Return to “Your Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest

cron