php - Adding frineds with the use of emails stored in the database -


i have been working on add friend system quiet sometime now, when got 1 won't work , don't know why please appreciated

<?php session_start();  include('config.php'); if(isset($_post['submit'])){      $user_id = $_get['user_id'];     $email  = isset($_post['added_id']);           $connect = mysql_connect('localhost', 'root', '') or die('error searching host');         $db = mysql_select_db('9jahivemobile') or die('could not find database');              $query = "select * admin email = '".$email."'";             $numrows = mysql_num_rows($query);             if ($numrows ==1){                 echo 'found!';                     $insert = 'insert connected ("adder_id", "added_id") values ("'.$user_id.'" "'.$email.'")';                      echo'hooray request have been sent';                      $redirect = 'profile.php';                     header("location: $redirect");             }else{                      $fail = 'fail.php';                     header("location: $fail");                      exit();                  } } ?> 

you creating query string, not doing mysql_query() it. also, remove where in insert query -

$query = "select * admin email = '".$email."'"; 

and

 $insert = 'insert connected ("adder_id", "added_id") values ("'.$user_id.'" "'.$email.'")'; 

try -

$query = mysql_query("select * admin email = '".$email."'"); 

and

 $insert = mysql_query('insert connected ("adder_id", "added_id") values ("'.$user_id.'" "'.$email.'")'); 

please sanitize data (http://php.net/manual/en/function.mysql-real-escape-string.php), , read on depreciation of mysql_* (http://php.net/manual/en/function.mysql-query.php) functions. update mysqli or pdo - http://php.net/manual/en/mysqlinfo.api.choosing.php


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -