<form
name="myform" id="myform" method="post"
action="add_comment.php">
<h2>Please leave a comment:</h2>
<input type="text" id="username"
name="username" value="Enter Username" /><br
/>
<input type="text" id="email"
name="email" value="Enter Email" /><br />
<textarea id="comment" name="comment">Enter
Comment</textarea><br />
<br
/><br />
<input type="checkbox" id="notify_box"
name="notify_box" value="Y">
Notify me when a new post is published. <br />
<br
/>
<input type="submit" value="Post Comment">
</form>
<?php
<?php
$notify = "";
$uName = $_POST['username'];
$eMail = $_POST['email'];
$comment= $_POST['comment'];
if(isset($_POST['notify_box'])){ $notify =
$_POST['notify_box']; }
//
send the data to the database
?>
When
executing the program....
“Warning:
Undefined index:”
We
can fix this using the isset() function too. But on this instance, we
can just ignore it by hiding the notices like this.
<?php error_reporting(E_ALL
^ E_NOTICE);?>
The
code should be like this==>>>
<?php
if(isset($_POST)){
$notify
= "";
$uName = $_POST['username'];
$eMail = $_POST['email'];
$comment= $_POST['comment'];
if(isset($_POST['notify_box'])){ $notify =
$_POST['notify_box']; }
//
send the data to the database
}
?>
No comments:
Post a Comment