Hello Dear Brothers & Sisters
how are you....?
Well, i am facing a problem while handling a script and database.
actually i am trying to shift some data (user id form database) form one page to another. through $_GET (if you have any other technique also suggest.)
and after transfring i grap that data through $_GET. and now i want to put that id from url to database for future use. and for that purpose i am using poster_id() function. it works fine normally i checked it through echo. but when i put this funtion in INSERT statement of mysql it put always "0" in database. why?
Please guide me. also i am new user of PHP.
<?php
require 'connect.php';
if(!empty($_GET["id"]) && !empty($_GET{"Summary"})){
echo $id = $_GET["id"].'<br>';
echo $summary = $_GET["Summary"].'<hr>';
}
function poster_id(){
if(!empty($_GET["id"]) && !empty($_GET{"Summary"})){
$id = $_GET["id"];
return $id;
}
}
//echo $one = poster_id();
if(isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["textArea"])){
$name = $_POST["name"];
$email = $_POST["email"];
$textArea = $_POST["textArea"];
if(!empty($name) && !empty($email) && !empty($textArea)){
$id = poster_id();
$query = "INSERT INTO coments VALUES('', '$id', '$name','$email','$textArea')";
if($query_run = mysql_query($query)){
echo $id = poster_id();
}
}
}
?>
HTML CODE HERE
<form action="test.php" method="POST">
Your Name:<input type="text" name="name" size="25">
E-mail address:<input type="text" name="email" size="30"><br>
<textarea cols="69" rows="10" name="textArea"></textarea>
<input type="submit" value="Submit">
</form>