jsmknow Posted August 23, 2008 Share Posted August 23, 2008 Iam making a login on my homepage and its going fine in some ways.. its a login that connect to my mysql database, so I want it to be safe.. But i got a problem... If you dont type anything in the form it just goes on to a member page for a member that doesnt exist.. Can any here plx help me, tell me how to make it so it tells if you havent typed anything and just stay on that page..? here the piece of code that i know is about that problem.. ///////////////////// function PWT() { $afsender=$_POST['afsender']; $navn=$_POST['navn']; if ($afsender=="index") { $password=$_POST['kodeord']; if ($navn=="Admin") { if ($password=="knowhq") return $navn; } else { $query="SELECT kodeord,besog FROM indianer WHERE indianernavn='$navn'"; $ud=mysql_query($query); $data = @mysql_fetch_row($ud); $kodeord=$data[0]; $besog=$data[1]; if ($password==$kodeord) { $besog=$besog+1; $query="UPDATE indianer SET besog=$besog WHERE indianernavn='$navn'"; mysql_query($query); return $navn; } } return "/passwordfejl"; } ///////////////////// Link to comment https://forums.phpfreaks.com/topic/121027-solved-i-need-help-here-about-validation-in-this-form/ Share on other sites More sharing options...
ohdang888 Posted August 23, 2008 Share Posted August 23, 2008 your login is very unsafe. you need to prevent injections... $afsender= mysql_real_escape_string($_POST['afsender']); $navn=mysql_real_escape_string($_POST['navn']); to check to see if its empty: if(empty($navn) or empty($afsender)){ echo "You must type something"; die(); } EDIT: if you want it so that they can't press submit until they've typed something, you've got use to javascript Link to comment https://forums.phpfreaks.com/topic/121027-solved-i-need-help-here-about-validation-in-this-form/#findComment-623877 Share on other sites More sharing options...
jsmknow Posted August 23, 2008 Author Share Posted August 23, 2008 But where do i have to put that piece that check? in the end or? Link to comment https://forums.phpfreaks.com/topic/121027-solved-i-need-help-here-about-validation-in-this-form/#findComment-623878 Share on other sites More sharing options...
ohdang888 Posted August 23, 2008 Share Posted August 23, 2008 put that in the very beginning Link to comment https://forums.phpfreaks.com/topic/121027-solved-i-need-help-here-about-validation-in-this-form/#findComment-623886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.