the input
PHP Code:<?php
$name=$_POST['name'] ;
$location=$_POST['location'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
if ($submit)
{
if($name&&$comment)
{
$insert=mysql_query("INSERT INTO $table (name,location,comment) VALUES ('$name','$location','$comment')") ;
echo mysql_error();
header('Location: succes.php');
}
else
{
echo "please fill all the fields";
}
}
?>
the output
PHP Code:<?php
$getquery=mysql_query("SELECT * FROM $table ORDER BY id DESC");
while($rows=mysql_fetch_array($getquery))
{
$id=$rows['id'] ;
$name=$rows['name'] ;
$location=$rows['location'] ;
$comment=$rows['comment'] ;
$comment2=wordwrap($comment, 80, "<br />", true);
echo "<div id='comment' align='left'><b>Name: </b>$name <br /><b>Location: </b>$location<br /><br /><b><i>Comment:</i></b><br />$comment2<br /><hr size='1'></div>"
;}
echo mysql_error();
?>
action script
PHP Code:<?php
require('boondocksconnect.php');
if(isset($_POST['submit']))
$name = $_POST['name'] ;
$location = $_POST['location'];
$comment = $_POST['comment'];
$submit = $_POST['submit'];
if((!$name) || (!$comment)){
echo "please fill all the fields";
}else{
mysql_query("INSERT INTO episode1 (name,location,comment) VALUES ('$name','$location','$comment')") ;
header('Location: succes.php');
}
?>
the form
HTML Code:<form action="comment_boondocks_episode1.php" method="post"> <table> <tr><td colspan ="2"><h3>Add a Comment</h3></td></tr> <tr><td>Name:</td><td><input type="text" name="name" /></td></tr> <tr><td>Location:</td><td><input type="text" name="location" /></td></tr> <tr><td colspan ="2">Comment:</td></tr> <tr><td colspan ="2"><textarea name="comment" rows="10" cols="60" ></textarea></td></tr> <tr><td colspan ="2"><input type="submit" name="submit" value="comment" /></td></tr> </table> </form>
is there any way I could use a single action script with a variable hidden form
and call that hidden variable in the input output???
thanks in advance skela


Reply With Quote

Bookmarks