Jump to content

Search the Community

Showing results for tags 'select query error sign up new user'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. Hi. ive been struggling for 2 hours over this and i just cannot understand whats wrong here. im trying to create a signup.php where there is a form in the index. with post method, and the inputs are username, password and confirmed password. in the php file i some functions (like isExist($username) which return true if someone wanna sign up with a username that already exist..) im embedding the code here: <?php //First define some functions.. function isExist ($username){//Return TRUE if name already exist in users table $query = "SELECT * FROM users WHERE username = $username"; $result = mysqli_query($con, $query) or die ('Cannot use SELECT query'); return (mysqli_num_rows($result) != 0);//Since username can be only 1 per name, any number !=0 means 1 actually.. } function passChk($password, $conf_pass){//Return TRUE if pass and confirmed pass match return ($password == $conf_pass); } function newUser ($username, $password){//Add a new user .. duh ;p if (!isExist($username)) { if (passChk($pass, $conf_pass)){ $query = "INSERT INTO 'users' (username, password, id) VALUES ('$username', '$password')"; mysqli_query($con, $query) or die ("Cannot INSERT into Database"); echo 'Username Created successfully'; } else {echo '<script>alert ("Password and confirmed password do not match")</script>'; header("Location: http://www.sweiss.co.il/sfn/index.html"); } } else { echo '<script>alert ("Username already exist!")</script>'; header("Location: http://www.sweiss.co.il/sfn/index.html"); } mysqli_close($con); } //Code start require_once('connectvars.php'); $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('Cannot create connection to Database'); mysqli_set_charset($con, "utf8") or die ('Could not set utf-8');//Will allow us to use hebrew $username = mysqli_real_escape_string($con, trim($_POST['username']));//Defence vs sql injection $password = mysqli_real_escape_string($con, trim($_POST['password'])); $conf_pass = mysqli_real_escape_string($con, trim($_POST['conf_pass'])); newUser ($username, $password); ?> i keep getting the error from the first function isExist.. cannot use SELECT query. plase any help would be much appriciated
×
×
  • Create New...