Menu

[Solved]Need Code Converted Able Connect Online Domain Code Online Domain Also Shows Connection Li Q37018983

I need the code converted below to be able to connect to myonline domain

My code for my online domain. Also shows connection islive. Make the two php files connect to this!:

   $servername = “localhost”;
   $db_username = “jstedman”;
   $db_password = “password”;
   $dbname = “onlinejob”; //Database name

    
try  
{
    $conn = newPDO(“mysql:host=$servername;dbname=$dbname”, $db_username,$db_password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
     
    echo “Connected successfully onlinejob”;
} catch (PDOException $e)  
{
    echo “Connection failed: ” .$e->getMessage();
}

login-exec.php

   //Start session
   session_start();
  
   //Include database connection details
   require_once(‘includes/config.php’);
  
   //Array to store validation errors
   $errmsg_arr = array();
       //Validation error flag
   $errflag = false;
  
   //Connect to mysql server
   $link = mysql_connect(‘localhost’,’root’,””);
   if(!$link) {
       die(‘Failed to connect to server: ‘. mysql_error());
   }
  
   //Select database
   $db = mysql_select_db(onlinejob, $link);
   if(!$db) {
       die(“Unable to selectdatabase”);
   }
  
   //Function to sanitize values received from the form.Prevents SQL injection
   function clean($str) {
       $str = @trim($str);
       if(get_magic_quotes_gpc()) {
           $str =stripslashes($str);
       }
       returnmysql_real_escape_string($str);
   }
  
   //Sanitize the POST values
   $username = clean($_POST[‘username’]);
   $phone = clean($_POST[‘phone’]);
  
   //Input Validations
   if($username == ”) {
       $errmsg_arr[] = ‘usernamemissing’;
       $errflag = true;
   }
   if($phone == ”) {
       $errmsg_arr[] = ‘phonemissing’;
       $errflag = true;
   }
  
   //If there are input validations, redirect back to thelogin form
   if($errflag) {
       $_SESSION[‘ERRMSG_ARR’] =$errmsg_arr;
       session_write_close();
       header(“location:login.php”);
       exit();
   }
  
  
   //$pass=$_POST[‘txtpassword’];
   $password = md5($password);
  
   //Create query
   $qry=”SELECT * FROM registration WHEREusername=’$username’ AND phone =’$phone'”;
   $result=mysql_query($qry);
  
   //Check whether the query was successful or not
   if($result) {
       if(mysql_num_rows($result) > 0){
           //LoginSuccessful
          session_regenerate_id();
           $member=mysql_fetch_assoc($result);
          $_SESSION[‘SESS_username’] = $member[‘username’];
          $_SESSION[‘SESS_phone’] = $member[‘phone’];
             
          session_write_close();
          header(“location: searchjob.php”);
           exit();
       }else {
           //Loginfailed
          header(“location: login.php”);
           exit();
       }
   }else {
       die(“Query failed”);
   }
?>

(Referred in login-exec.php) config.php:

DEFINE(‘DATABASE’,’onlinejob’);
DEFINE(‘DBUSER’,’root’);
DEFINE(‘DBPASS’,”);
DEFINE(‘HOST’,’localhost’);
include(‘includes/functions.php’);
?>

Expert Answer


Answer to I need the code converted below to be able to connect to my online domain My code for my online domain. Also shows conne… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *