Added: 3 years ago
From: phpacademy
Views: 77,719
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (205)

Sign In or Sign Up now to post a comment!
  • Guys if you get a undefined index error, just use a ternary operator, it doesn't hide the error:

    $submit = isset($_post['submit']) ? $_post['submit'] : '';

    //form data

    $fullname = isset($_post['fullname']) ? $_post['fullname'] : '';

    $username = isset($_post['username']) ? $_post['username'] : '';

    $password = isset($_post['password']) ? $_post['password'] : '';

    $repeatpassword = isset($_post['repeatpassword']­) ? $_post['repeatpassword'] : '';

  • md5decrypt(dot)org

  • ok, so i added the @ before _POST['submit']; so the error messages went away, but it doesn't want to echo out whatever i input. any ideas?

  • can u put ur .php in the description so that we, as newbies here can follow of what u're putting starting from part 1? i just want to see the codes that u added. :( thanks :)

  • God bless you man! Your tutorials have been extremely...thanks and God bless!!

  • Fatal error: Can't use function return value in write context in C:\xampp\htdocs\bautista\login­.php on line 20

    my line 20 is if ($username == $dbusername&&md5($password) = $dbpassword)

    why does it says fatal error

  • @lenoj02 remove one of the = signs

  • Guys if you get a undefined index error, just add a @ at the begining of all $_POST in your register.php. For example:

    $submit = @$_POST['submit'];

    //form data

    $fullname = @$_POST['fullname'];

    $username = @$_POST['username'];

    $password = @$_POST['password'];

    $repeatpassword = @$_POST['repeatpassword'];

    if ($submit)

    it worked for me

  • Comment removed

  • @XxRedDude can someone explain why this is so? doesnt help much to just put it in without explanation even though it does work after putting in the @ symbol. any help would be much appreciated

  • @XxRedDude Thanks for the tip.But what does the @ do for us?

  • @kobi1974 If you have trouble with errors in PHP, you can add an at sign before an called function, or like in the example, before a variable. It will suppress the warnings that normally come up when there is one.

  • @MrYoranimo Thank you again.

  • @XxRedDude Putting @ in front of the posts won't stop the actual error it will just hide the error message.

  • IMO, MD5 is obsolete. i personally use SHA256 for now (longer character length, but more secure), ie. at least until SHA-3 is released. :)

  • @TheMrSly can you write sha256 the same way he is writing md5? Doesn't seem to work for me.

  • plzzzz help me i get this error Call to undefined function mysql_connect()... 

  • 6:50 your MD5, ITS OVER 9000!

  • I don't see how md5 improves security... It can easily be decrypted.

  • @charmanderstail Im sitting here thinking the same thing, first thing i thought of when i saw this was to type in md5 reverse and sure enough first link , works every time. They really should improve this by switching to a system with 10 dif types of encryption or more and having it use one of them at random or something along those lines . anything is better than this ridiculous bs

  • @FFWDEntertainment Yeah but even if you did get hacked and the hackers got the encrypted passwords somehow, I suppose they might not know it's md5... but they could probably just try out every type of encryption they know of.

  • @charmanderstail are you shitting me? do you really believe someone who doesn't know how to hack into a database doeskin know the basics of working with php & mysql? if anything I think coming up with your own encryption script and putting it on a seperate server/ labeling the pw field something random and unexpected like user_avatars and just adding a .jpg extension on the end would throw someone off better than this.

  • @FFWDEntertainment I know that would be a lot more secure but md5 does provide some security... just not much.

  • '@' will not issue a notice if the index $_POST['fullname'] doesn't exist. THATS WHAT IT DOES. :) like.

  • Why do you not get same errors as me!

  • Notice: Undefined index: submit in C:\xampp\htdocs\login_registra­tion_nahid\register.php on line 4

    Notice: Undefined index: fullname in C:\xampp\htdocs\login_registra­tion_nahid\register.php line 7

    Notice: Undefined index: username in C:\xampp\htdocs\login_registra­tion_nahid\register.php line 8

    Notice: Undefined index: password C:\xampp\htdocs\login_registra­tion_nahid\register.php line 9

    when i click register button,nothing happened .anybody can email correct answer:nahidchow@gmail.com

  • to @bikenb1 or themightyrobofish who ever posted the code if isset and to put all of the stuff in the if statement thank you very much i have no index errors during his echo statement and to all of who wants the code with no errors heres the code

    if( isset($_POST['submit']) && $_POST['submit']){

    // Initialise $_POST variables eg:

    $fullname = $_POST['fullname'];

    $username = $_POST['username'];

    $password = $_POST['password'];

    $repeatpassword = $_POST['repeatpassword'];

    echo"$username/etc

  • Comment removed

  • wootowot

  • Notice: Undefined index: submit in C:\xampp\htdocs\SiteB\Register­.php on line 2

    Notice: Undefined index: fullname in C:\xampp\htdocs\SiteB\Register­.php on line 4

    Notice: Undefined index: username in C:\xampp\htdocs\SiteB\Register­.php on line 5

    Notice: Undefined index: password in C:\xampp\htdocs\SiteB\Register­.php on line 6

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\SiteB\Register­.php on line 7

  • @tonytrfd thats the same problem as mine :(

  • @tonytrfd i got the same error too but once i set the items they went away...i suppose it was b/c the variabled werent being used

  • Awesome tutorial!

    I'm from Austria and I nearly understand everything! Thanks!

    But I have a problem...

    When I click on "submit"

    it only appears "$username" and not the chosen username :(

    What shall I do?

  • If you get "Undefined Index" error then use this code

    if($_SERVER['REQUEST_METHOD'] == "POST")

    Use the code for both "form data" and echoing out $username and so on!

    I tried the code provided by other comments,they worked without errors but would not echo out what i wanted it to.

  • If you think we can do this without you providing all of the php/html codes your crazy.

  • Comment removed

  • Using this

    error_reporting(0);

    I have made the errors go away, would this effect anything?

  • md5 is easy crackable, this tutorial should stats crypt(string) is better.

  • @csyicker Is this true? I've found plenty of so called MD5 Cracks, but I can't find a way to crack the md5 versions of my passwords in the DB. Doesn't Crypt() also mean your encrypted value in the database is tied to that single server. If so good luck migrating your DB to another server.

  • If $_POST['submit'] is not set, then $submit wont be set either. So you will have to check whether they have been set using the isset function:

    if(isset($submit))

    {

    echo "$username/$password/$repeatpa­­ssword/$fullname";

    }

  • @avatarraid still not working :(

  • Comment removed

  • Comment removed

  • Comment removed

  • I have the exact thing as you and still not getting rid of the undefined index: error wats wrong wit

    if($submit)???

  • still getting some errors:

    Notice: Undefined index: submit in B:\xampp\htdocs\keysmasters\lo­ginsession\register.php on line 5

    Notice: Undefined index: fname in B:\xampp\htdocs\keysmasters\lo­ginsession\register.php on line 6

    Notice: Undefined index: lname in B:\xampp\htdocs\keysmasters\lo­ginsession\register.php on line 7

    Notice: Undefined index: username in B:\xampp\htdocs\keysmasters\lo­ginsession\register.php on line 8

  • where can i download your code ;))

  • Hey dude!!! Notice: Undefined Index (I Think its on $_POST) because my PHP Version are Latest (2011) please repair it!

  • I am getting error when I am using the below code $submit= strip_tags(& $_POST['submit']); $fullname=strip_tags(& $_POST['fullname']); $username=strip_tags(&$_POST['­username']); $password=md5(strip_tags(&$_PO­ST['password'])); $repeatpassword=md5(strip_tags­(&$_POST['repea­tpassword'])); so someone please help me below is the error Deprecated: Call-time pass-by-reference has been deprecated in C:\xampp\htdocs\register.php on line 14 and so on till line18
  • I found out THE SOLUTION!

    For all the persons who are using phpmyadmin online, to fix all those errors you just need to remove the "//form data" !!!!

    all the errors will be fixed!

    Thumbs up if it worked for you!

  • Notice: Undefined variable: _post in C:\xampp\htdocs\Loginsystem\re­gister.php on line 4

    Notice: Undefined variable: _post in C:\xampp\htdocs\Loginsystem\re­gister.php on line 5

    Notice: Undefined variable: _post in C:\xampp\htdocs\Loginsystem\re­gister.php on line 6

    Notice: Undefined variable: _post in C:\xampp\htdocs\Loginsystem\re­gister.php on line 7

  • @romano8524 yeah thats my error too !!!

  • Can anyone explain the @ thing?

  • Notice: Undefined index: submit Notice: Undefined index: fullname Notice: Undefined index: username Notice: Undefined index: password Notice: Undefined index: repeatpassword The solution is: $submit = @$_POST['submit']; $fullname = strip_tags(@$_POST['fullname']­); $username = strip_tags(@$_POST['username']­); $password = strip_tags(@$_POST['password']­); $repeatpassword = strip_tags(@$_POST['repeatpass­word']);
  • @semaca2005 Thank you! Thank you!

  • whats the point of encrypting your passwords when if someone managed to get in your database can use MD5 decrypter.

  • MD5 can be decrypted

  • Comment removed

  • You should add some salt to the encryption. Otherwise the password is easily hackable using an rainbow table.

  • Guys.. This is self explainable. If you have errors, look at your script again. No need to post in comments, because all PHP errors are minor.. including the ones above. Sorry about being rude, but for someone like me who's seriously experienced in PHP it makes me cringe that people don't even know this much yet. :-/

  • @Acceptable76 Please take a look at the video you're commenting on before saying stupid things. This is a tutorial which is obviously meant for people to LEARN. If we all would be experts like you're assuming, we wouldn't be watching this video!

  • @ZTOID Yeah, I kind of regret saying that, I was in a cocky mood. :-)

  • your voice is music to my ears. ^^

  • md5 has been cracked

  • Notice: Undefined index: submit in C:\xampp\htdocs\register.php on line 7

    Notice: Undefined index: fullname in C:\xampp\htdocs\register.php on line 11

    Notice: Undefined index: username in C:\xampp\htdocs\register.php on line 12

    Notice: Undefined index: Password in C:\xampp\htdocs\register.php on line 13

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\register.php on line 14

    what is this plz sent exact code

  • @bikenb1 Read my comment below, it explains what is wrong with the code and what you need to do to ammend it.

  • @themightyrobofish .sory i didn't get it plz mail me code in my biken_b@yahoo.com .I am waiting for it.........

  • Notice: Undefined index: submit in C:\xampp\htdocs\register.php on line 7

    Notice: Undefined index: fullname in C:\xampp\htdocs\register.php on line 11

    Notice: Undefined index: username in C:\xampp\htdocs\register.php on line 12

    Notice: Undefined index: Password in C:\xampp\htdocs\register.php on line 13

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\register.php on line 14

    Your Full Name:

    Choose a username:

    Choose a Password:

    Repeat Your password:

  • Hi all.

    You're getting the "Undefined index" error because the $_POST values you are trying to reference in the php code are not set until the form has been submitted. The best way around this is to add an if statement at the beginning of your php code which uses 'isset' to verify these values exist before trying to manipulate them.

    The code you need to add is:

    if( isset($_POST['submit']) && $_POST['submit']){

    // This code will only run if $_POST['submit'] is set.

    }

  • @themightyrobofish

    Man thanks, that helped alot

  • @themightyrobofish

    infact, it may just be the best thing since sliced bread?

  • @themightyrobofish It doesn't work

  • @bikenb1 It does work, but you need to put ALL of your php code inside of the if statement I gave you originally. Remembering that the post data 'submit' that the if statement is checking for are those set in your html form which are passed through the $_POST function. Its really not hard.

    Again, the code you need to add is:

    if( isset($_POST['submit']) && $_POST['submit']){

    // Initialise $_POST variables eg:

    $first_name = $_POST['first_name'];

    // etc..

    }

  • @themightyrobofish then i get Notice: Undefined variable: submit in D:\xampp\htdocs\site\register.­php on line 31

  • Comment removed

  • @themightyrobofish did tht still doesnt change anything

  • @themightyrobofish Thanks but it didn't help.. I added that to the register.php file. Is that what I'm supposed to do?

  • @themightyrobofish you have to take out the space like:

    if (isset($_POST['submit'])){

    // This code will only run if $_POST['submit'] is set.

    }

  • I keep getting an "undefined index" error message, but when I submit the form when it's all empty it goes away. I think it needs a default value or something could you please help?

  • Hi the solution of submit button is quite easy try give a name to your input

    input type='submit' name='submit' value='register'

    now $submit=$_POST['submit'];

    should work.

  • instead of using the md5() function, you're better off using the hash('sha256, $password)

  • if password is gonna be encrypted so why to strip tags for it?

  • need help!

  • plz stop posting wrong code. this dont work $submit = $_POST['submit']; $fullname = strip_tags($_POST['fullname'])­; $username = strip_tags($_POST['username'])­; $password = strip_tags($_POST['password'])­; $repeatpassword = strip_tags($_POST['repeatpassw­ord']); errors------------------------­-------- Undefined index: submit Undefined index: fullname Undefined index: username Undefined index: password Undefined index: repeatpassword
  • @69hwoarang You fail.

  • Comment removed

  • ive fixed part of the script but i still get this

    Notice: Undefined variable: submit

  • i am using WAPM

  • i have error

    Notice: Undefined index: submit

    Notice: Undefined index: fullname

    Notice: Undefined index: username

    Notice: Undefined index: password

    Notice: Undefined index: repeatpassword

    Notice: Undefined variable: submit

    WHAT SHOUD I DO ?

  • @DAREDEVIL94reaL kill yourself

  • Help PLEASE! The method="post"> isn't working!! after i press submit nothing happens! It just redirects me to regpage again !! Help please!

  • I got this error "Deprecated: Call-time pass-by-reference has been deprecated in C:\xampp\htdocs\register.php on line 8" when i tried to put md5 on &$_POST['password'] and &$_POST['rpword'] but i fixed it by declaring $password and $rpassword as md5.

    e.g

    $password = &$_POST['username'];

    $rpassword = &$_POST['rpassword'];

    $pw = md5 ("$password");

    $rpw = md5("$rpassword");

    Hope it helps guys.

  • Thank you iTwistar that worked perfectly. The warnings are gone and everything works the way I want them too as soon as I publish my site I will leave a link in the comment area of the last tutorial in this series which is Email activation(part5) . Now my thanks to phpacademy for theses tutorials I never touched or really looked at PHP or HTML before a week ago. Thank again and keep them coming. Very good tutorials easy to understand and learn from.

  • I keep getting a Parser error at the submit - $_POST['submit'] part. What is the solution to this problem?

  • are these tutorials out of order or..?

  • Solution for strip tag:

    $usernamer=&$_POST['username']­;

    $passwordr=&$_POST['password']­;

    $rPasswordr=&$_POST['rPassword­'];

    $username = strip_tags($usernamer);

    $password = md5(strip_tags($passwordr));

    $rPassword = md5(strip_tags($rPasswordr));

  • OK the solution

    $submit =&$_POST['submit];

    and the rest of the &$_POST work for a minute and then when you start to do

    $fullname = strip_tags(&$_POST['fullname']­);

    gives a Deprecated: Call-time pass-by-reference has been deprecated in C:\xampp\htdocs\register.php on line 9

    I have gone all the way through to the Changing password tutorials and every thing works but just need to get rid of the Warnings any thoughts on that.

  • solution here:

    $submit= & $_POST['submit'];

    $fullname=& $_POST['fullname'] ;

    $username=&$_POST['username'];

    $password=&$_POST['password'];

    $repeatpassword=&$_POST['repea­tpassword'];

  • @Jimd5353  It worked. Tough , i don`t really understand why.

  • just getting errors EG/

    Notice: Undefined variable:_post in C:xampp/htdocs/test/resgister.­php on line 4

    and line 7, 8, 9 and 10 need help.

  • it says Notice: Undefined index: submit in C:\xampp\htdocs\Browsergame\re­gister.php on line 3

    Notice: Undefined index: fullname in C:\xampp\htdocs\Browsergame\re­gister.php on line 4

    Notice: Undefined index: username in C:\xampp\htdocs\Browsergame\re­gister.php on line 5

    Notice: Undefined index: password in C:\xampp\htdocs\Browsergame\re­gister.php on line 6

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\Browsergame\re­gister.php on line 7

  • @Guitaremalte I keep getting the same errors as you! Has anyone got a solution?!

  • @Guitaremalte did you found a solution ? please write back

  • @DAREDEVIL94reaL no sorry I didn^

    t

  • @Guitaremalte

    I've got the same problem as you had. Any ideas yet?

  • @Guitaremalte I too Got the same error.. Someone please help me..

  • @Guitaremalte

    i wonder, could you please please please make a video on why this might be happening? i cant think of anything that could be causing it for us and not you :(

  • @jakewestgomila

    Just add @ in front of the $_post of each variable

    $submit = @$_POST ['submit'] ; $firstname = @$_POST ['firstname'] ; $lastname = @$_POST ['last

  • @jokak001 what does @ do, specifically? Anyway, it works! Finally! Thank you very much!

  • @jokak001 Thanx a lot i did 2 it works !

  • @jokak001 Thank you!!

  • @jokak001 TNX A LOT!!!!

  • Comment removed

  • Comment removed

  • @Guitaremalte Add an @ sign before declaring the variables.

  • @Grkgermn333 this @ really works

    thnx great

    btw what's the logic of '@' here..

  • @zaris22 From php.net:

    "When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored."

  • @Grkgermn333 thnx prfctly undrsood......gr8 tutorial

  • @Guitaremalte These are only "Notices" they do not terminate the rest of the code like regular Errors do... from now on what you should do is add an @ symbol in front of all of the $_POST variables to tell the code to ignore notices thrown by the $_POST variable. hope i explained this properly... the answer to your question lies here:

    phpacademy(dot)com/

    register-login-user-registrati­on-part-2-t692.html#p3563

  • @Guitaremalte I'm getting the same notices

  • Alex!

    Can You Send Hole Register system to my email

    plese

    plese

    becuse i have many error in it

  • Thank you very much man!! very helpful!!

  • im getting an error saying:

    Notice: Undefined index: submit in C:\xampp\htdocs\loginsession\r­egister.php on line 4

  • Hi ggetting this error plz solve as soon

    Notice: Undefined index: submit in C:\xampp\htdocs\fyp\register.p­hp on line 3

    Notice: Undefined index: fullname in C:\xampp\htdocs\fyp\register.p­hp on line 5

    Notice: Undefined index: username in C:\xampp\htdocs\fyp\register.p­hp on line 6

    Notice: Undefined index: password in C:\xampp\htdocs\fyp\register.p­hp on line 7

    Notice: Undefined index: repeatpassword in C:\xampp\htdocs\fyp\register.p­hp on line 8

  • @SibteinTv do it like this:

    $fullname = $_POST["fullname"] = "undefine";

    $username = $_POST["username"] = "undefine";

    $password = $_POST["password"] = "undefine";

    $repassword = $_POST["repassword"] = "undefine";

  • @TheHumanBanana but this returns undefine when i put username pass and press register it returns undefine in all fields like this undefine/undefine/undefine/und­efine

  • @SibteinTv

    I had the same errors mate, but I just followed PeterLifeOnline's advice

    put &before the $_POST['username'];

    simply : & $_POST['username'];

  • Great Job

  • oh i solved that problem by putting & before $_POST exemple:

    $fullname = &$_POST['fullname'];

    but now when i put md5 i get and error

    Deprecated: Call-time pass-by-reference has been deprecated in C:\xampp\htdocs\c4php\loginses­sion\register.php on line 10

  • @PeterLifeOnline what hapen if you put @ instead of &

  • @PeterLifeOnline did you find out the solution? dealing with the same problem here. write back please

  • @hantataru Forget this tutorial, i have seen others way more easy... this you problably can´t put on internet because it's local host...

    so just search for other tutorials outside youtube..

  • help me... please!!

    great tutorials i am subscribe you right now :)

  • Undefined index: submit in C:\xampp\htdocs\c4php\loginreg­ister\register.php on line 4

    why!? I Try everything what is wrong?

    $submit = $_POST['submit'];

  • Your tuts helped me a lot :)

    Show me some ads bro I'll click 25times :) a nice way to donate :)

  • I Love You alex

    Thankyou So Much For teaching us without any greed

  • What can casue this error?

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'localhost' (using password: YES) in C:\adress\registerDOTphp on line 12

    Error connecting to mysql

  • love you dude! your the man!!

  • Alex your are the best.. love your tutorials!

  • when i go on my register.php page before filling the form in or clicking the button, i get the following error -- Notice: Undefined index ....

  • Comment removed

  • Wow man I appreciate all these tutorials

  • thanks.......I learn lot!!!!!

  • $submit = $_POST['submit']; GETING PROBELM :(

  • @theamirjee check your submit button's code has " name='submit' " or not.

  • Well nice trick actually, you set your username to an image, and when it's echoed it will display the image

  • that's odd

    this code won't work.

    the part where you put Register after the echo won't work. why is that?

  • Well mine didn't work...As of about 4 minutes in.