Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Notice: Undefined index

JohnYXJohnYX CebuMember Posts: 3

can some one help me with this please;

Notice: Undefined index: username in P:\easyphp\www\Violet Registration Form\index.php on line 9

Notice: Undefined index: email in P:\easyphp\www\Violet Registration Form\index.php on line 10

Notice: Undefined index: password in P:\easyphp\www\Violet Registration Form\index.php on line 11

<?php $mysql_hostname = "localhost"; $mysql_user = "root"; $mysql_password = ""; $mysql_database = "johnXY"; $prefix = ""; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database"); mysql_select_db($mysql_database, $bd) or die("Could not select database"); $username=$_POST['username']; $email=$_POST['email']; $password=$_POST['password']; $query="INSERT INTO `member`(`username`, `email`, `password`)VALUES('".$username."', '".$email."', '".hash('sha256', $password)."')"; $data = mysql_query ($query)or die(mysql_error()); mysql_close(); ?>

Comments

  • ebypaulebypaul WayanadMember Posts: 1

    In some cases, there wont be any POST data so it will be showing error. Use isset() function inside the if statement.

  • rohitrohit Member Posts: 1
    if(isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']))
    {
        $username=$_POST['username']; 
        $email=$_POST['email']; 
        $password=$_POST['password']; 
    
        $query="INSERT INTO `member`(`username`, `email`, `password`)VALUES('".$username."', '".$email."', '".hash('sha256', $password)."')"; 
        $data = mysql_query ($query)or die(mysql_error()); 
        mysql_close(); 
    }
    
  • ccir105ccir105 KathmanduMember Posts: 4

    Make proper validation of every user input before using them. Like using isset empty function and checking proper datatype of the varible is recommend before inserting into database.

Sign In or Register to comment.