FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


help with reply problem





bartdou
write-reply.php shows a certain message(here is the msg which id=4) you wanna reply,and give a textarea for you to write reply content.
here is writereply.php
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>reply</title>
</head>

<body>
<p align="center">MY GUESTBOOK</p>

<?php
$id=4;  //this page reply msg id=4

echo"<textarea class='samllArea' cols='38' name='reply' rows='4'></textarea>";
echo"<a href='reply.php?id=$id'>REPLY1</a>";

echo"<FORM METHOD='POST' ACTION='reply.php'><textarea class='samllArea' cols='38' name='reply' rows='4'></textarea><INPUT TYPE='submit' NAME='' alue="REPLY2"></FORM>";
?>

</body>
</html>


reply.php writes the related data into the databse
reply.php:
Code:
<?php
$dbhost="localhost";  //
$dbname="mydata";     //
$dbusername="root";   //
$dbpassword="";       //
$id=$_GET[id];
$reply=$_POST[reply];

echo $reply;
echo $id;
$db=mysql_connect($dbhost,$dbusername,$dbpassword);
if($id){echo"success!<br>";}

/*
mysql_select_db($dbname,$db);
$sql="UPDATE guest SET retime=NOW() WHERE id='$id'";
$result=mysql_query($sql,$db);    //reply time
$sql="UPDATE guest SET reply='$reply' WHERE id='$id'";
$result=mysql_query($sql,$db);    //reply words
echo"<center>";
echo"reply succeeds!<a href=show.php>BACK</a></b>";
*/

?>


Write "something" in the textarea of REPLY1 and then click text link "REPLY1", the reply.php shows: 4success!
Write "something" in the textarea of REPLY2 and then click submit button "REPLY1", the reply.php shows: something

How to AT THE SAME TIME transfer "reply" and "id" to reply.php so that the codes between /* */ of reply.php can work?
hexkid
$_GET and $_POST are tow very distinct arrays.

$_GET is an array with the values specified in the URL;
$_POST is an array with the values submitted on a form.

You may want to use $_REQUEST instead, which is a mixture of these two arrays and the $_COOKIES array.

Or you may put the URL parameter in the form action
Code:
<form method="post" action="reply.php?id=4">
<!-- ... -->
</form>
Related topics
FTP Codes
FTP error codes -- What they mean
Frihost DC (Distributed Computing) Project
Very large problem[SOLVED]
[HELP] PC PROBLEM (don't bind)
How to turn a nice thought into a serious idea?
IONCUBE DECODER PROBLEM
Please I need help in the serverq
Help! Installation Problem.
Please Help Packet Problem
Howto not get your Programmering Question answered
PHP noob problem
help for problem! how to do?
Still i have that ftp problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.