I've a html form for get Id from visitor
<form action="show.php" method="post">
<p>Your id: <input type="text" name="id" /></p>
<p><input type="submit" /></p>
</form>
and the php file for act this .
<?php
$id = ((int)$_GET["id"]);
$con=mysql_connect('localhost','user','pass');
mysql_select_db('dbname',$con);
$query="SELECT * FROM `users` WHERE id = '$id'";
$select=mysql_query($query);
while($row=mysql_fetch_array($select)){
echo $row['name'];
}
mysql_close($con);
?>
but it's not working , can't read id , pelase help me for resolve this issue
Thank you
php $id = ((int)$_POST["id"]); .... Save this answer.
An id on a <form> tag assigns an identifier to the form. The identifier must be unique across the page.
The id attribute specifies a unique id for an HTML element. The value of the id attribute must be unique within the HTML document. The id attribute is used to point to a specific style declaration in a style sheet. It is also used by JavaScript to access and manipulate the element with the specific id.
Can you use input tag without form? Yes, you can have a valid input without a form.
You are submitting data via POST. Thats defined by the attribute "method" within your form tag:
<form action="show.php" method="post">
So data will not be stored in $_GET but in $_POST.
So to access the ID use $_POST['id'] not $_GET['id']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With