easy question

Reply

Join Date: Aug 2008
Posts: 94
Reputation: designingamy is an unknown quantity at this point 
Solved Threads: 0
designingamy designingamy is offline Offline
Junior Poster in Training

easy question

 
0
  #1
Sep 16th, 2008
Easy question, except I don't know how to do it. I want to ask for user's email address and then have them confirm it. How do I use php to check to make sure the confirmation matches the first email address entered?

Thanks in advance!
~Amy
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: easy question

 
0
  #2
Sep 16th, 2008
  1.  
  2. <form id="form1" name="form1" method="post" action="">
  3. <label>Email
  4. <input type="text" name="email1" />
  5. </label>
  6. <p>
  7. <label>Confirm Email
  8. <input type="text" name="email2" />
  9. </label>
  10. </p>
  11. </form>
  12.  
  13. <?php
  14.  
  15. $email1=email1;
  16. $email2=email2;
  17.  
  18. if ($email1 == $email2)
  19. echo "Emails are the same!";
  20. else
  21. echo "Emails are Incorrect!";
  22. ?>
Last edited by mattyb15; Sep 16th, 2008 at 9:53 am.
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 26
Reputation: mattyb15 is an unknown quantity at this point 
Solved Threads: 0
mattyb15 mattyb15 is offline Offline
Light Poster

Re: easy question

 
0
  #3
Sep 16th, 2008
I'm not exactly crash hot at PHP so im not 100% sure thats correct, but i thought i'd give it a shot.
If I helped +rep please,
Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 139
dickersonka dickersonka is offline Offline
Veteran Poster

Re: easy question

 
0
  #4
Sep 16th, 2008
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

  1. if(strcmp($email1, $email2)==0){
  2. echo "Emails are same";
  3. } else {
  4. echo "Emails are Incorrect";
  5. }
Last edited by dickersonka; Sep 16th, 2008 at 11:15 am.
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 84
Reputation: MVied is an unknown quantity at this point 
Solved Threads: 5
MVied's Avatar
MVied MVied is offline Offline
Junior Poster in Training

Re: easy question

 
0
  #5
Sep 16th, 2008
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. :/

  1. <form id="form1" method="post" action="">
  2. <fieldset>
  3. <legend>E-mail</legend>
  4. <label for="email1">Email</label>
  5. <input type="text" name="email1" />
  6. <label for="email2">Confirm Email</label>
  7. <input type="text" name="email2" />
  8. </fieldset>
  9. </form>
  10.  
  11. <?php
  12. $email1 = $_POST['email1'];
  13. $email2 = $_POST['email2'];
  14.  
  15. if (strcmp($email1, $email2) == 0) {
  16. echo "Emails are the same!";
  17. } else {
  18. echo "Emails are not the same!";
  19. }
  20. ?>
Last edited by MVied; Sep 16th, 2008 at 11:55 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 94
Reputation: designingamy is an unknown quantity at this point 
Solved Threads: 0
designingamy designingamy is offline Offline
Junior Poster in Training

Re: easy question

 
0
  #6
Sep 16th, 2008
Easy enough!
Thanks to you all!
~Amy
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 84
Reputation: MVied is an unknown quantity at this point 
Solved Threads: 5
MVied's Avatar
MVied MVied is offline Offline
Junior Poster in Training

Re: easy question

 
0
  #7
Sep 16th, 2008
I made a ton of edits to my post. I kept noticing errors, lol. I've been doing this too long.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 635 | Replies: 6
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC