Notice: Undefined index - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Notice: Undefined index

JohnYXJohnYX CebuPosts: 3Member

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(); ?>


  • ebypaulebypaul WayanadPosts: 1Member

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

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

    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.