Skip to content

Instantly share code, notes, and snippets.

@alashstein
Created June 23, 2018 12:05
Show Gist options
  • Save alashstein/d83ee3ab3e19bd2f256611eb98625226 to your computer and use it in GitHub Desktop.
Save alashstein/d83ee3ab3e19bd2f256611eb98625226 to your computer and use it in GitHub Desktop.
<?php
$link = mysqli_connect("localhost", "newuser", "password", "proj1");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt select query execution
$q = $_GET['q'];
$sql = "SELECT * FROM t2 WHERE f1 = '$q'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
$row = mysqli_fetch_array($result);
$loc = $row['f2'];
}
}
mysqli_close($link);
header('Location: '.$loc);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment