JavaScript
x
<!doctype html>
<html>
<head>
<title>Post Answer</title>
</head>
<body>
<?php
include ("connection.php");
$result = mysqli_query($con, "SELECT * FROM student_table WHERE SID='$_POST[sid]'") or die('Query failed');
$tmp = mysqli_fetch_array($result);
$nn = $tmp['nickname'];
$a = $_POST['answer'];
$sid = $tmp['SID'];
$c = $tmp['course'];
$q_id = $_POST['q_id'];
$sql = mysqli_connect("127.0.0.1", "root", "", "project");
$sql = "INSERT INTO answer_table (nickname, answer, SID, vote, course) VALUES ('$nn', '$a', '$sid', '', '$c')";
if (!mysqli_query($con, $sql)) {
die('Error: ' . mysqli_error($con));
}
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.location.href='question.php';
window.alert('Thank You! Your answer is online now.')
</SCRIPT>");
?>
</body>
</html>
At question.php
file, I want to receive $q_id
as $_GET['q_id']
Can I pass $q_id
of line 17 to question.php
page of line 26?
Advertisement
Answer
Just add it in as a query string in the javascript
JavaScript
echo ("<script language='JavaScript'>
window.location.href='question.php?q_id=$q_id';
window.alert('Thank You! Your answer is online now.')
</script>");