www.webdeveloper.com
Results 1 to 8 of 8

Thread: Registration Form/Contact list but without Login

  1. #1
    Join Date
    Jul 2013
    Posts
    5

    Registration Form/Contact list but without Login

    Hey all, I need some help.
    I've done a lot of searching but can't find exactly what I'm looking for.

    To give you a little insight in what I'm after, we have a supporters club and we want the supporters to fill in a registration form (so we have a record of their details) which will have:
    First name (required), Last name (required), Email (required), Address (optional), Contact Number (optional) and Official Membership number (optional).

    After clicking "submit it will take them to a "Thank you page". All that info has to be integrated into our website template.

    I would like it to connect to a db, which will store all the data and give the person a supporters membership number.

    I am not after a login page or anything like that, the only person that can access the info would be me via the db.

    Everything I have seen always has a login, username, password ect.
    I'm not asking for people to write up a code for me, what I'm hoping for is for someone to point me in the right direction, a website or free script to download.
    I'm not to crash hot at php coding, just so you know, that's why I just dl anything I need.

    Thanks in advance

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    720
    So - on your page you place some text to invite them to register and then a submit button labeled "Register".

    In your php script, if you see that they clicked on the "Register" button, you open a new script called "registerusers.php". This new script will send the user to a new screen with all the input fields you desire and a "Save" button. Upon receiving the "Save" button submission your registerusers script will accept all the input fields, validate them, escape them, etc. and then do a table update. If successful send them back a thank you message, else send back the same page with the values still in it and an error message.

    Is that the guidance you seek?

  3. #3
    Join Date
    Jul 2013
    Posts
    5
    Thanks for your reply and yes something like that is what I'm after.

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    720
    What else do you need? Follow that plan and show us what you come up with for more help.

  5. #5
    Join Date
    Jul 2013
    Posts
    5
    I don't need anything else. That's the problem I can't find anything remotely close to that, I've seen on here a few login scripts but they only have username and password coding.

  6. #6
    Join Date
    Jul 2013
    Posts
    5
    Ok I found something which I've adjusted, but I'm getting an error on line 88, here is the code

    <?php
    if($_POST['formSubmit'] == "Submit")
    {
    $errorMessage = "";

    if(empty($_POST['formFirstName']))
    {
    $errorMessage .= "<li>You forgot to enter your First Name!</li>";
    }
    if(empty($_POST['formSurname']))
    {
    $errorMessage .= "<li>You forgot to enter your Surname!</li>";
    }
    if(empty($_POST['formEmail']))
    {
    $errorMessage .= "<li>You forgot to enter your Email!</li>";








    $varFirstName = $_POST['formFirstName'];
    $varSurname = $_POST['formSurname'];
    $varAddress = $_POST['formAddress'];
    $varPhone = $_POST['formPhone'];
    $varEmail = $_POST['formEmail'];
    $varMembership = $_POST['formMembership'];


    if(empty($errorMessage))
    {
    $fs = fopen("mydata.csv","a");
    fwrite($fs,$varSurname . ", " . $varFirstName . $varEmail . "\n");

    fclose($fs);

    header("Location: thankyou.html");
    exit;
    }
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>My Form</title>
    </head>

    <body>
    <?php
    if(!empty($errorMessage))
    {
    echo("<p>There was an error with your form:</p>\n");
    echo("<ul>" . $errorMessage . "</ul>\n");
    }
    ?>
    <form action="membership.php" method="post">
    <p>
    First Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="formFirstName" maxlength="50" value="<?=$varFirstName;?>" /> *Required
    </p>
    <p>
    Surname:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <input type="text" name="formSurname" maxlength="50" value="<?=$varSurname;?>" /> *Required
    </p>

    <p>
    Address:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <input type="text" name="formAddress" maxlength="70" value="<?=$varAddress;?>" /> *Optional
    </p>

    <p>
    Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;
    <input type="text" name="formPhone" maxlength="15" value="<?=$varPhone;?>" /> *Optional
    </p>

    <p>
    Email:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;
    <input type="text" name="formEmail" maxlength="50" value="<?=$varEmail;?>" /> *Required
    </p>

    <p>
    Membership No:&nbsp;
    <input type="text" name="formMembership" maxlength="20" value="<?=$varMembership;?>" /> *Optional
    </p>


    <input type="submit" name="formSubmit" value="Submit" />
    </form>
    </body>
    </html>

  7. #7
    Join Date
    Jul 2013
    Posts
    5
    I fixed that error message I forgot a } after this line
    {
    $errorMessage .= "<li>You forgot to enter your Email!</li>";

    so how's this code looking? next question is how do I proceed from here, getting it to open a new script called "registerusers.php" then to get it into a db?

  8. #8
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    720
    You don't necessarily need a new script - I just said that because a lot of people here seem to work that way.

    Since you are already combining multiple activities in your single script above, simply add some more code to handle the 'register' button like you do already with the 'Submit' button.

    Plus - I hope you don't write your php code with all those blank lines normally. Bad Practice. Will cause you problems at some point when you try to send a header.

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