SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru CJ's Avatar
    Join Date
    Apr 2000
    Location
    Mechelen, Belgium, Europe
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I dunno if I need to add something to the script, or that I just need to use some code in some kind.

    My PHP knowledge: 0

    I d/loaded a script I can use as 'formmailer' it has neat features. It redirects a user to a pge after submitting which I can make and I can add the contents of the form fields submitted as text in the form of {NAMEOFFIELD} this works.

    Now it also allows you to redirects a user to a specific page I can make when the email isn't correct. But the {NAMEOFFIELD} won't work on that page because it isn't a 'template'. (I think)

    Is there anyway to call the form elements which were correct on the error page so the person only needs to fill in his email address without hitting the back button?

    The script is at http://freesources.net/other/contact/general

    Christophe

  2. #2
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea it would involve setting the values of the filled fields to the name of the same field that was sent. So it would be like:

    Code:
    <input type=textbox name=namefield value=<?php echo ("$namefield"); ?>
    >
    
    or if you want it to say something in the field if its empty you could do the following
    
    <input type=textbox name=namefield value=
    <?php
    if ($namefield) {
    echo ("$namefield");
    }
    else {
    echo ("Please enter this field in");
    ?>
    >
    This probably looks confusing but it would be easier to explain if you posted the source to your program.

    [Edited by jumpthru on 09-14-2000 at 01:06 AM]

  3. #3
    SitePoint Guru CJ's Avatar
    Join Date
    Apr 2000
    Location
    Mechelen, Belgium, Europe
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The source is quite long... but I will try what you suggested and if it doesn't work I'll contact you jumpthru

    Christophe

  4. #4
    SitePoint Guru CJ's Avatar
    Join Date
    Apr 2000
    Location
    Mechelen, Belgium, Europe
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    No the thing doesn't work. It displays nothing. I tried several variables (or how ya call it) but none worked.

    Jumpthru: I'll try to find your ICQ somewhere

    Christophe

  5. #5
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am hardly on ICQ, but I just got on. Anyways if I am never on you can email me and arrange a time or something.

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I alwasy find it easier to keep it all on one page.

    You basically have a form and a processor on the same page so if there are errors you can keep access to the variables they submitted. See my sample code here and you shouild be able to figure it out.

    if ($submit) {
    $error = 0;

    if (!$name) {
    $error = 1;
    $errors[] = "Missiing Name";
    }
    if (!$email) {
    $error = 1;
    $errors[] = "Missiing Email";
    }

    if ($error == 0) {

    if (mail($to, $subject, $body)) {
    $sent = 1;
    }
    else {
    print "Error sending mail";
    exit;
    }
    }


    }


    if ($errro == 1) {
    print "<ul>";
    while (list($key, $val) = each ($errors)) {
    print "<li>".$val;
    }
    print "</ul>";
    }
    if (!$submit || ($error == 1)) {
    printf('<form action="%s" method="post">', $PHP_SELF);
    printf('<input type="text" name="name" value="%s"><br>', $name);
    printf('<input type="text" name="email" value="%s"><br>', $email);
    printf('<input type="submit" name="submit" value="submit">');
    printf('</form>');

    }
    if ($submit && ($sent == 1)) {
    print "Thanks YOu your form was submitted successfully";
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Wizard jumpthru's Avatar
    Join Date
    Apr 2000
    Location
    Los Angeles, California
    Posts
    1,008
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if ($errro == 1) {
    print "<ul>";
    That line should actually be

    Code:
    if ($error == 1) { 
    print "<ul>";

  8. #8
    SitePoint Guru CJ's Avatar
    Join Date
    Apr 2000
    Location
    Mechelen, Belgium, Europe
    Posts
    684
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    correct me if I'm wrong but shouldn't tere be some else clause?



    Christophe

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doesn't have to be! You can check for stuff with if clauses all day long. Basically in this scenario there only be three paths to follow. One the user hasn't clicked submit, the user has clicked submit and there is an error. Or the user clicked submit and the email was sent. The first if clause above the form checks for the first two scenarios with: if(!$submit || ($error == 1)) The if clause after the form checks for the third. if ($sent == 1) The if clause near the top if ($submit) delegates which path is to be followed after it exits this if clause. So with something this simple this will work fine.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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