Php redirect with variable -


i trying use

  header("location: http://www.mysite.com/gamecode.php?gameid=$pw"); 

below code.

   <?php header("location: http://www.mysite.com/gamecode.php?gameid=$pw"); $con = mysqli_connect("localhost","placeholder","placeholder","placeholder");  //or die ('unable connect');   // check connection  if (mysqli_connect_errno())  {   echo "failed connect mysql: " . mysqli_connect_error();   }    //create random table name    $alpha = "abcdefghijklmnopqrstuvwxyz";    $numeric = "0123456789";   $special = ".-+=_,!@$#*%<>[]{}";   $chars = "";    if (isset($_post['length'])){   // if want form above   if (isset($_post['alpha']) && $_post['alpha'] == 'on')     $chars .= $alpha;  if (isset($_post['alpha_upper']) && $_post['alpha_upper'] == 'on')     $chars .= $alpha_upper;  if (isset($_post['numeric']) && $_post['numeric'] == 'on')     $chars .= $numeric;  if (isset($_post['special']) && $_post['special'] == 'on')     $chars .= $special;  $length = $_post['length']; }else{ // default [a-za-z0-9]{9} $chars = $alpha . $numeric; $length = 6;  } $len = strlen($chars); $pw = '';   ($i=0;$i<$length;$i++)     $pw .= substr($chars, rand(0, $len-1), 1);   // finished password  $pw = str_shuffle($pw);  //using $pw variable table name  $sql="create table `" . $pw . "` (  pid int not null auto_increment,   primary key(pid),  name char(15))";  if (mysqli_query($con,$sql))  {  echo "table created";   }   else  {   echo "did not create table";  }      mysqli_close($con); 

above page trying add variable url. the page redirect not adding header variable redirect should.

try like

header('location: http://www.yoursite.com/new_page.php?gameid='.$gmid); 

you need change quotes before variable or can try double quotes like

header("location: http://www.yoursite.com/new_page.php?gameid=$gmid"); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -