www.webdeveloper.com
Results 1 to 10 of 10

Thread: [RESOLVED] How to get HTML form post values after email validation

  1. #1
    Join Date
    Jan 2007
    Posts
    78

    resolved [RESOLVED] How to get HTML form post values after email validation

    I'm trying to write form values to a CSV file AFTER I have validated an email address using a crude form of Double Opt in;
    I'm using a modified version of code shown here:
    http://www.php-scripts.com/php_diary/example37.phps

    Everything works except I can't capture the form values except the email address.

    There's a section where it says
    // add the email to your double opt-in list here

    After that, I've tried to get the values to post to the CSV file, but I only get the email value. The other form fields dont get posted.

    I've tried POST & REQUEST to get the posted variables.
    Neither one seems to work.

    If I create a separate php file at the end, everything gets posted correctly, but I only want to post the emails that have been validated.

    Any ideas welcome.

  2. #2
    Join Date
    Sep 2013
    Posts
    221
    Why dont you try out with empty field validation in HTML.

    You are missing the required <form> element. Here is how your code should be like:
    function IsEmpty(){
    if(document.forms['frm'].question.value == "")
    {
    alert("empty");
    return false;
    }
    return true;
    }

    HTML:

    <form name="frm">
    Question: <input name="question"/> <br />
    <input id="insert" onclick="return IsEmpty();" type="submit" value="Add Question"/>
    </form>

    Hope this helps you.

  3. #3
    Join Date
    Jan 2007
    Posts
    78
    Thanks priyankagound;
    Not sure I understood exactly what you meant. I am posting the values from the first page. I send the email of to be confirmed by the sender to make sure that they are the one who is requesting to be signed up. What I want is that AFTER they have responded, I want to add their info to a CSV file, but only AFTER they have responded.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    Maybe you just need to make sure that the email address along with all the other form fields are within the same <form> tag?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jan 2007
    Posts
    78

    How to get HTML form post values after email validation

    My form tag has name , phonenumber etc.. all in the same form
    Code:
    <input type="text" name="name" size="32">
    <input type="text" maxlength="8" name="phonenumber" size="21">
    I even tried to put the variables in sessions & that didn't work

    Like

    $_SESSION['phonenumber'] = $_POST['phonenumber'];


    I can't see why I dont have access to the sessions to be able to post them to the CSV file.

    TO post I've tried

    Code:
    $phonenumber = $_SESSION['phonenumber'];
    $savestring = $name . "," . $areacode . "," . $phonenumber. "," .$email .  "," . $date ."\n";
    I've modified it like

    $phonenumber = $_POST['phonenumber'];

    Still Not working

    I've NEVER has SESSIONS NOT work after trying all these angles!

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    Okay, time-out: are we talking about finishing up the process in a separate script request from an email link?

    If so, what I would do is store all the info submitted originally in the DB, but flagged as unconfirmed. Then the email link would include a unique identifier for that record, which would be used by the target script to mark that record as confirmed.

    An alternative would be to add the additional fields to the email's link as URL query string name/value pairs that would then be in $_GEt.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jan 2007
    Posts
    78
    Thanks NogDog:

    RE: are we talking about finishing up the process in a separate script request from an email link?

    Yes! & I was afraid you would say something like that.
    If I was using MySql, understandable, but with CSV files,That's my problem here.

    How do I append $name & $phonenumber to this validation script that is sent out. My efforts are probably clouded by my Brain fog.
    Code:
    $mail_body = "To validate this email click the following link:\nhttp://www.mysitedomain.net/Scripts/Client-links.php?e_addy=$from&m=$hashed";

  8. #8
    Join Date
    Mar 2013
    Posts
    1
    Quote Originally Posted by simora View Post
    I'm trying to write form values to a CSV file AFTER I have validated an email address using a crude form of Double Opt in;
    I'm using a modified version of code shown here:
    http://www.php-scripts.com/php_diary/example37.phps

    Everything works except I can't capture the form values except the email address.

    There's a section where it says
    // add the email to your double opt-in list here

    After that, I've tried to get the values to post to the CSV file, but I only get the email value. The other form fields dont get posted.

    I've tried POST & REQUEST to get the posted variables.
    Neither one seems to work.

    If I create a separate php file at the end, everything gets posted correctly, but I only want to post the emails that have been validated.

    Any ideas welcome.


    If you are trying to any type of help regards the HTML coding then there is no need to worry because i am going to suggest you a portal as www.w3schools.com/
    l from where you can get help as well as coding according to your need.

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    I would just add some url-encoding:
    PHP Code:
    $mail_body "To validate this email click the following link:\nhttp://www.mysitedomain.net/Scripts/Client-links.php?e_addy=".urlencode($from)."&m=".urlencode($hashed); 
    (if $hashed is something like an MD5 string, it probably won't really need to be urlencoded, but it doesn't hurt, so might as well be safe.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  10. #10
    Join Date
    Jan 2007
    Posts
    78
    Thanks again NogDog:

    url-encoding did the trick. Also,rather than using SESSIONS, You can specifically request the values again to write to a CSV file as in

    $name = $_REQUEST['name'];

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles