I have a form set up like this
<DOCTYPE HTML>
<html>
<head>
</head>
<body>
<? php
$id = $_GET['id'];
$conn = mysqli_connect('localhost', 'nabeel', 'nab33l', 'rabbi');
$query = "SELECT * FROM poetry WHERE id = ".$id.";"
$result = mysqli_query($conn, $query);
$rows = mysqli_fetch_assoc($result);
$Id = $rows[Id];
$title = $rows[title];
$author= $rows[author];
$entry= $rows[entry];
<form method="post" action="../">
<label>ID</label><br>
<input type="text" id="" name="Id" value='$Id'><br>
<label>TITLE</label><br>
<input type="text" id ="" name= "title" value=$title><br>
<label>Author</label><br>
<input type="text" id="" name= "author" value=$author><br>
<label>Entry</label><br>
<input type="text" id="" name= "entry" value=$entry><br>
<label>Time & Date</label><br>
<input type="datetime-local" id="" name= "timeanddate" value=$timeanddate ><br>
<input type= 'hidden' name='form_submitted', value='1'>
<br>
<input type="submit" value="Submit" ><br>
?>
</form>
</body>
</html>
Now I cannot seem to call the variables declared in php tag any where else. I could move the form inside the php tag but I wanted to know if there was some proper way to achieve this.
You need to put a <?php echo $variable ?>
around your variable. (and you may declare it globally)
If the variable is user input you have a perfect XSS Vector by the way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.