Passing parameter through "window.location.href"

user3520573
<!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?

Seth

Just add it in as a query string in the javascript

echo ("<script language='JavaScript'>
         window.location.href='question.php?q_id=$q_id';
         window.alert('Thank You! Your answer is online now.')
       </script>");

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Passing parameters using Window.location.href

From Dev

Communication between controllers through $window.location.href

From Dev

Pass parameter with window.location.href to MVC ActionResult

From Dev

Second parameter on window.location.href gets NULL on Controller

From Dev

String is not a function on window location href

From Dev

window.location.href not working

From Dev

Java - Passing a method through a parameter

From Dev

Java - Passing a method through a parameter

From Dev

Enable and disable window.location.href

From Dev

onclick window.location.href with input value

From Dev

Javascript window.location.href onClick not working

From Dev

onchange event on window.location.href

From Dev

Window.location.href infinite loop

From Dev

Stubbing window.location.href with Sinon

From Dev

window.location.href not working in IE 11

From Dev

Using a variable for if window.location.href.indexOf()

From Dev

$window.location.href NOT WORKING in AngularJS

From Dev

window.location.href appending instead of replacing

From Dev

JavaScript window.location.href not working in localhost

From Dev

window.location.href is not redirecting html page

From Dev

window.location.href not working on IE

From Dev

How to Pass QueryString in window.location.href?

From Dev

onclick window.location.href with input value

From Dev

window.location.href - help redirecting

From Dev

Use of window.location.href in crosswalk

From Dev

window.location.href and hash are not working on chrome

From Dev

Window.location.href infinite loop

From Dev

Javascript window.location.href onClick not working

From Dev

find a tag that contains the window.location.href

Related Related

HotTag

Archive