I need to check if the input is a valid email or not if the email is not valid then it would ask again for the mail address without refreshing the whole page
[embed=425,349]
please help me out
thanks in advance
I need to check if the input is a valid email or not if the email is not valid then it would ask again for the mail address without refreshing the whole page
[embed=425,349]
please help me out
thanks in advance
mods please help me its urgent … I am in trouble …Please help me fast
If you need to do something without refreshing the page you should look into using javascript.
Either
javascript validation
you can compare fields or use regex to validate them in pure javascript. Or you could use some validation library to validate the fields.
ajax
you could use javascript to post the email field to a php file which will do some validation and return true or false.
okey let it get refreshed but it should display message and ask for input again
thanks but it is not working can you please edit the file and give it to me it would be very helpful i am new to it.
please help me i cant understand a single bit of it i have a deadline going to end in one hour.
all that is required is when the email is entered and its not a valid the page should display a message and the cursor should blink again in email area
phtmlfile.txt (19.6 KB)
Then you should’ve begun this task earlier, sorry but this forum isn’t here to write code for you.
If you re-read your latest post you don’t really come off as someone interested in learning.
sir you are getting me wrong i am trying from morning but its not working
here is the code i have written
[php]error_reporting(E_ALL);
if($_POST[‘submit’]==“India”)
{
if(isset($_POST[‘EMAIL’]))
{ //only do file operations when appropriate
$a = test_input($_POST[“EMAIL”]);
if (!preg_match("/([\w-]+@[\w-]+.[\w-]+)/",$email))
{
show_error(“Enter a valid E-mail address!”);
}
exit();
$myFile = “email_users.txt”;
$d=date(“d-m-y”);
$r="\n";
$s=$_POST[‘submit’];
$fh = fopen($myFile, ‘a+’) or die(“can’t open file”);
fwrite($fh, $a.’,’.$d.’,’.$s.’,’.$r);
fclose($fh);
}
}
if($_POST[‘sub’]==“Overseas”)
{
if(isset($_POST[‘EMAIL’]))
{ //only do file operations when appropriate
$b = test_input($_POST[“EMAIL”]);
if (!preg_match("/([\w-]+@[\w-]+.[\w-]+)/",$b))
{
$emailErr = “Invalid email format”;
}
$my = “email_users.txt”;
$e=date(“d-m-y”);
$t="\n";
$u=$_POST[‘sub’];
$f = fopen($my, ‘a+’) or die(“can’t open file”);
fwrite($f, $b.’,’.$e.’,’.$u.’,’.$t);
fclose($f);
}
}[/php]
And since PHP is rendered server side you can’t do it with PHP if you don’t want to reload the page.
Have a go at it using javascript.
Well first things first you come to this website because you got a job on something you did not know how to do, the deadline is here and now you are frantic. first thing you should have done is show ALL of the code that is in question! on stackoverflow where you were freaking out you actually showed more code you happen to show that your show_error function is completely empty! of course it is not going to show:
[php]function show_error($myError)
{[/php]
you have functions named, if you come asking for help you should show all your functions which you are including in the script otherwise you are handing us half a book and asking for a full report on the book! it is impossible for a programmer to look at half the code and give you a definitive answer that he can be confident in. he has no idea what you put in the functions and if you are struggling with this then who knows there most likely would be errors in your functions as well!
all the email checking would be done once a person clicks submit, if there was an error then “die” the script, echo error message!
php can do anything
No, it can not validate form fields without reloading the page.
LMAO JimL sorry about that I did not even pay attention that the whole deal was without reloading the page!! Yeah You need javascript!