Jump to content

rich_hemmo

New Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by rich_hemmo

  1. Hi guys I know this might be a repeated post, someone has looked at the code and they seem to think that it all look fine, but I'm getting this following message again

    Warning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\submit-form.php on line 19
    The following SQL Failed INSERT INTO 'users' ('firstname', 'lastname', 'username', 'confirmusername', 'password', 'confirmpassword', 'email' ,'confirmemail') VALUES ('richard', 'Hemmings', 'hemmo001', 'hemmo001', 'password', 'password', 'richardgwhemmings@msn.com' , 'richardgwhemmings@msn.com')

    I just cant seem to see where I'm going wrong, at first there was a single quote missing from firstname' this I have now addressed, I've been woriking on this now for 2 weeks today!

    Config.php

    <?php 
    
    $connection = mysqli_connect("localhost","root","","registration");
    
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    
    mysqli_close($connection);
    ?>
    

    submit-form.php

    <?php
    $connection = mysqli_connect("localhost", "root", "", "registration") or die("Error!!");
    //select your database
    //$b=mysql_select_db("Registration",$a);
    $firstname=$_POST['firstname'];
    $lastname=$_POST['lastname'];
    $username=$_POST['username'];
    $confirmusername=$_POST['confirmusername'];
    $password=$_POST['password'];
    $confirmpassword=$_POST['confirmpassword'];
    $email=$_POST['email'];
    $confirmemail=$_POST['confirmemail'];
    //Database connection
    require_once("config.php");
    
    //mysql query to insert value to database
    $query = "INSERT INTO `users` (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email`, `confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$confirmusername', '$password', '$confirmpassword', '$email', '$confirmemail')";
    $result = mysqli_query($connection,$query);
    //if value inserted successyully disply success message
    if(!$result) {
    
        die("The following SQL Failed $query");
    }
    echo 'Registred successfully..!!</div>';
    ?>
    

    Any help would be appreciated 

  2. Hi Guys I'm creating my own website and I want users to be able to register and log in at the momnet I'm just having trouble with letting users to log in 

     

    here is the code 

     

    config.php 

    <?php 
    
    $connection = mysqli_connect("localhost","root","","registration");
    
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    
    mysqli_close($connection);
    ?>
    
    

    This is the submit_form.php

    <?php
    
    //select your database
    //$b=mysql_select_db("database_name",$a);
    $firstname=$_POST['firstname'];
    $lastname=$_POST['lastname'];
    $username=$_POST['username'];
    //$confirmusername=$_POST['confirmusername'];
    $password=$_POST['password'];
    $confirmpassword=$_POST['confirmpassword'];
    $email=$_POST['email'];
    $confirmemail=$_POST['confirmemail'];
    //Database connection
    require_once("config.php");
    
    //mysql query to insert value to database
    $query="INSERT INTO 'users' (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')";
    
    $result = mysqli_query($connection,$query);
    //if value inserted successyully disply success message
    if(!$result) {
    
        die("The following SQL Failed $query");
    }
    echo 'Registred successfully..!!</div>';
    ?>
    

    This is the error message that I'm getting 

     

    Warning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\submit-form.php on line 19
    The following SQL Failed INSERT INTO 'users' (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('richard', 'Hemmings', 'hemmo001', 'password', 'password', 'richardgwhemmings@msn.com' , 'richardgwhemmings@msn.com')

     

    Can anyone shed any light onto the problem please?

     

    Thanks in advance 

     

    Rich

  3. Hi Guys I'm in the middle of creating my own website and I'm having trouble with letting users to register I have created the code but when I click on the "submit" button I'm getting a blank white screen 

    config.php

    <?php 
    //Mysql Connect  |   mysql_connect("host= 3306","username","");
    //Below example to connect in localhost
    $a=mysql_connect("localhost","root","");
    
    //select your database
    $b=mysql_select_db("database_name",$a);
    ?>
    

    and this is the submit_form.php

    ?php
    $firstname=$_POST['firstname'];
    $lastname=$_POST['lastname'];
    $username=$_POST['username'];
    //$confirmusername=$_POST['confirmusername'];
    $password=$_POST['password'];
    $confirmpassword=$_POST['confirmpassword'];
    $email=$_POST['email'];
    $confirmemail=$_POST['confirmemail'];
    
    //Database connection
    require_once("config.php");
    
    //mysql query to insert value to database
    $query=mysql_query("INSERT INTO registration (`firstname`, `lastname`, `username`, `confirmusername`, `password`, `confirmpassword`, `email` ,`confirmemail`) VALUES ('$firstname', '$lastname', '$username', '$password', '$confirmpassword', '$email' , '$confirmemail')");
    
    
    
    //if value inserted successyully disply success message
    if($query)
    {
        
        echo 'Registred successfully..!!</div>';
    }else
    {
    //error message
        echo '<unable to registred !!</div>';
    }
    ?>
    

    Hope someone can help me and give me some pointers please 

    Richsubmit-form.phpconfig.phpregister.php

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.