Jump to content

Recommended Posts

<?php
//$passwordVerify = password_verify($userInput, $passwordInput);
    $con = mysqli_connect("127.0.0.1","root","");     if (!$con)     {         die('Could not connect: ' . mysqli_error());     }       /*if($con){           die('Database connected successfuly.');       }*/     $sql="CREATE DATABASE IF NOT EXISTS 'itech3108_30124248_a1'";               $runquery = mysqli_query($con,$sql);     if(!mysqli_select_db($con, "itech3108_30124248_a1"))     {         die('Database not connected: ' . mysqli_error());     }
    session_start();
    if(isset($_POST['register']))
    {    
        //for image uploading......................
        $files = $_FILES['file'];
        $filename = $files['name'];
        $filrerror = $files['error'];
        $filetemp = $files['tmp_name'];
        $fileext = explode('.', $filename);
        $filecheck = strtolower(end($fileext));
        $fileextstored = array('png' , 'jpg' , 'jpeg');

        if(in_array($filecheck, $fileextstored)){

            $destinationfile = 'img/'.$filename;
            move_uploaded_file($filetemp, $destinationfile);
        }
        $name = $_POST['username'];
        $email = $_POST['email'];
        $confirm = $_POST['confirm'];
        $profile=$_POST['profile'];
       /*$file_ext= null;
        if(isset($_FILES['image'])){
            $errors= array();
            $file_name = $_FILES['image']['name'];
            $file_size =$_FILES['image']['size'];
            $file_tmp =$_FILES['image']['tmp_name'];
            $file_type=$_FILES['image']['type'];
            $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
           
            $extensions= array('jpeg','jpg','png');
           
            if(in_array($file_ext,$extensions)=== false){
               $errors[]='extension not allowed, please choose a JPEG or PNG file.';
            }
           
            if($file_size > 2097152){
               $errors[]='File size must be excately 2 MB';
            }
           
            if(empty($errors)==true){
               move_uploaded_file($file_tmp,'img/'.$file_name);
               //echo 'Success';
            }else{
               print_r($errors);
            }
         }
        //$passwordhash = null;
        /*
        if (CRYPT_BLOWFISH == 1)
        {
            $passwordhash = password_hash($password ,PASSWORD_BCRYPT);
        }
        else
        {  
            echo '<script>alert('Blowfish DES not supported.');
            window.location='reg.php';</script>';
        }...............................................................*/
       // die('photo url='. $destinationfile.'name='.$name.'email='.$email.'password='.$password.'profile='.$profile);
        $sql = "INSERT INTO user ('name','email','password','profile') SET ('$name','$email','$confirm','$profile,'$destinationfile')" ;
       // $query="INSERT INTO 'user' ('id','name','email','password','profile','photo') VALUES( ?,?,?,?,?,?) ";
       // $stmt = mysqli_prepare($con, $query) or die(mysqli_error($con));
       // $stmt->bind_param($stmt,'Null',$name,$email,$confirm,$profile,$destinationfile);
        //$stmt->execute();

        //$stmt = mysqli_prepare($con, "INSERT INTO 'user' ('name','email','password','profile','photo') VALUES( ?,?,?,?,?) ");
       // mysqli_stmt_bind_param($stmt, $name,$email,$confirm,$profile,$destinationfile);
       // mysqli_stmt_execute($stmt);
               
        $runquery = mysqli_query($con,$sql);
        //echo 'query'.$runquery;
        if(!$runquery)
        {
           
             die( mysqli_error($con));
        }
        else
        {
            echo '<script>alert("User successfully registered.");
            window.location="login.php";</script>';
        }
    }
    //mysqli_query.close();
    if(isset($_SESSION['name']))
    {
        header('Location:profilepage.php');
    }
?>

<!DOCTYPE html>
<html>
<head>
    <title>Sign Up Page</title>
    <link href='https://fonts.googleapis.com/css?family=Lobster|Montserrat' rel='stylesheet'>
    <link rel='stylesheet' type='text/css' href='stylesheet/register.css'>
</head>

    <header>
        <nav>
            <h1>find Your Love</h1>
            <ul id='navli'>
                <li><a class='homeblack' href='home.php'>Home</a></li>
            </ul>
        </nav>
    </header>
    <style>
        body{
            background-image: url('img/love.jpg');
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-size: cover;}
    </style>
    <div class='divider'></div>
   
        <div class='loginbox'>
        <img src='img/love2.jpg' class='avatar'>
            <h1>Signup </h1>
            <form action='reg.php' method='POST'enctype='multipart/form-data'>
                <p>User Name</p>
                <input type='text' id='username' name='username' placeholder='Enter Username' required='requiored'></p>
               
                <p>Email</p>
                <input type='Email' id='email' name='email' placeholder='Enter email' required='required'>
               
                <p>Password</p>
                <input type='password' id='password' name='password' placeholder='Enter password' required='required'>

                <p>Confirm Password</p>
                <input type='password' id='confirm' name='confirm' placeholder='re-enter password' required='required'>

                <p> upload Image</p>
                <input class="input--style-1" type="file" placeholder="file" name="file">

                <p>Your Words</p>
                <input type='textbox' id='profile' name='profile' placeholder=' your words to describe your self' required='required'>
   
                <input type='submit' name='register' value='Sign Up'>

                <div class='divider'></div>
                <h6><a href='login.php'>Already Have Account ? </a></h6>
            </form>  
        </div>
    </body>
</html>

 

I am having an error with this code

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''name','email','password','profile') SET ('Sasural','kill@1234.com','kill','ANDK' at line 1

I am stuck with this for last 5hrs

Link to comment
https://forums.phpfreaks.com/topic/310736-insert-query-error/
Share on other sites

dear mate,

be precisely careful while  typing your code because even a single inverted comma will also effect your coding. for your problem try this...

$sql="INSERT INTO user (id,name,email,password,profile,photo)

VALUES( Null,'$name','$email','$confirm','$profile','$destinationfile') ";

Link to comment
https://forums.phpfreaks.com/topic/310736-insert-query-error/#findComment-1577763
Share on other sites

21 minutes ago, Prabin said:

$sql = "INSERT INTO user ('name','email','password','profile') SET ('$name','$email','$confirm','$profile,'$destinationfile')" ;

I stopped reading earlier when I spotted the quotes. Then I read the rest of the line. That syntax is completely wrong. You were almost there with the prepared statement that you apparently abandoned. A pity because that is the correct method, you should not be putting variable directly into the sql.

Omit id from the column list and the corresponding null in the values (that will happen anyway)

Your bind_param is missing the variable types eg ('ssss')

Link to comment
https://forums.phpfreaks.com/topic/310736-insert-query-error/#findComment-1577764
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.