| | |
easy question
![]() |
•
•
Join Date: Apr 2007
Posts: 26
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
<form id="form1" name="form1" method="post" action=""> <label>Email <input type="text" name="email1" /> </label> <p> <label>Confirm Email <input type="text" name="email2" /> </label> </p> </form> <?php $email1=email1; $email2=email2; if ($email1 == $email2) echo "Emails are the same!"; else echo "Emails are Incorrect!"; ?>
Last edited by mattyb15; Sep 16th, 2008 at 9:53 am.
If I helped +rep please,
Thanks
Thanks
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 139
Should work, but you might want to use this for strings
if you don't care about case use strcasecmp instead strcmp
if equal they will return 0
if you don't care about case use strcasecmp instead strcmp
if equal they will return 0
PHP Syntax (Toggle Plain Text)
if(strcmp($email1, $email2)==0){ echo "Emails are same"; } else { echo "Emails are Incorrect"; }
Last edited by dickersonka; Sep 16th, 2008 at 11:15 am.
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
And you probably want to declare the E-mail variables correctly. Also, paragraph tags within a form used in that way aren't exactly semantically correct. It's acceptable to use <br /> tags right after the labels or CSS floats if you want to help style your form rather than paragraph tags, as form elements aren't exactly paragraphs. Oh, and the name attribute on a form tag is not valid if you're using XHTML.
I'm a neat freak. :/
I'm a neat freak. :/
PHP Syntax (Toggle Plain Text)
<form id="form1" method="post" action=""> <fieldset> <legend>E-mail</legend> <label for="email1">Email</label> <input type="text" name="email1" /> <label for="email2">Confirm Email</label> <input type="text" name="email2" /> </fieldset> </form> <?php $email1 = $_POST['email1']; $email2 = $_POST['email2']; if (strcmp($email1, $email2) == 0) { echo "Emails are the same!"; } else { echo "Emails are not the same!"; } ?>
Last edited by MVied; Sep 16th, 2008 at 11:55 am.
![]() |
Similar Threads
- Easy Question (For You) (Python)
- hopefully easy question (C++)
- Im new and have an easy (I think) question (C++)
- Basic ASP Access question (ASP)
- Hopefully easy question about linking... (C++)
- EASY question? checking for line feed (return) in a html file with C++ (C++)
- A question of RAM (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: sleep function
- Next Thread: All who know how to use phpbb3 please read need you help to do something
Views: 635 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
access ajax apache array auto beginner binary box buttons cakephp check checkbox class cms code cookies css database date directory display download dropdown drupal dynamic echo email error file files form forms function functions header href htaccess html image images include insert ip java javascript joomla jquery limit link login lookup loop mail menu mlm mod_rewrite multiple mysql onclick order parse password paypal php post problem query radio redirect regex remote results rewrite script search security select server session soap sort source sql storage string syntax table update upload url user validate validation validator variable video web website wordpress xml






