www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: 2 scripts on the same page?

  1. #1
    Join Date
    Apr 2007
    Posts
    30

    2 scripts on the same page?

    I have a promo page where I have 2 forms; one is so the user can enter a competition and so I require a first name, last name, email fields and the other is where they can enter their email address to receive the latest news when we have any updates. I've tried to use both of these scripts; http://www.bignosebird.com/carchive/bnbform.shtml and http://www.codebrain.com/perl. They both work when I only have to impliment one form on the page but as soon as I try to do two on the page they don't work. I've made duplicates of the scripts, and called them different names aznd put both of these in the cgi-bin but that doesn't work - is there something obvious I'm doing wrong? I've put an example of the page up here: http://www.thinkingshed.com/bnbform/bnbform.html

    If anyone can help it'd be much appreciate - I'm not much of a coder so please be kind!

  2. #2
    Join Date
    Jan 2005
    Posts
    446
    first off...I looked at your code, and before you go one step further you have to remove that script from your site. Why you ask? Because I anyone can write an simple html page and use your script to send out spam...this is because you have the email to right on the website. You want a form script where the email address the data should go to is typed right into the script and not on the website itself. You are just asking for your website to be used as a spam box.

    As far as form generators, there is one that I have used that is simple and to the point...you can find it at www.clickhost.net/formgen.php

  3. #3
    Join Date
    Apr 2007
    Posts
    30
    Hi Sae - Argh I've just replied to the other post I made on the other forum and found out it was also from yourself! Thanks for that and for this, I've since removed all of these forms from my site and used that great form generator that you mentioned.

    Do you also happen to know the following:

    1. How can I create two seperate forms on the one page; one for a competition entry and one for a newsletter signup - from the form generator I can only seem to create one.

    2. Do you happen to know of any form generators so I can do a "refer this website" form on another page of the site?

    Thanks once again for being so helpful.

  4. #4
    Join Date
    Jan 2005
    Posts
    446
    You are right, that generator creates a php page that has the form and the form emailing function. To add both forms to the website you would have to extract the html form and then create two php files that would handle the emailing of both html forms. Post the two forms you created in a response so that I can take a look at them.

    A "refer this website" script would be really easy to create, but I am sure if you type in "refer this website php script" into google you'll get more than enough code examples.

    I am in a rush now so I can't go into more details, but post the two php scripts you created and we'll take it from there

  5. #5
    Join Date
    Apr 2007
    Posts
    30
    Hi, Thanks for the help to date but I think i'm just gonna have to give up - I've been trying this all day and now i'm getting other errors occuring! I'm not a programmer and find this stuff incredibly difficult. All that I wanted was on one page to have a name and email field so people could enter a competition along with another form, on the same page, so they could enter their email address to sign up for a newletter and then when they got taken through to a thank-you page they could refer a friend to the site.

    I know how to use Golive and a bit of CSS but apart from that it seems impossible to a non-programmer! I've got to go to bed noow (live in the UK so it's 11.30pm)

  6. #6
    Join Date
    Jan 2005
    Posts
    446
    I remember when I was trying to create my first form...it was very frustrating...so I know what you are going through, for that reason I am offering to create the forms for you.

    What I need is for you to copy the contents of the two files that you created using the form generator and paste them in a response here. If you use [ code ] before the code of the file and and [/ code ] at the end it will format the code in such a way that you can view it on the website. Something like this:
    Code:
    sample code
    *When posting code it's a good idea to not show your real email address so that spam bots don't email you like crazy.

  7. #7
    Join Date
    Apr 2007
    Posts
    30
    Hi Sae, thanks once again. The code generated is

    Form 1:

    <?php

    if (isset($submt)){


    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    if($Name=="" || $Email=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if($errors==1) echo $error;
    else{
    $message="Name: ".$Name."
    Email: ".$Email."
    ";
    mail("a@a.com","Form Submitted at your website",$message,"From: phpFormGenerator");
    header("Refresh: 0;url=http://www.thinkingshed.com/dev/thanks.html");
    }

    }else{
    ?>
    <form action='<? echo $PHP_SELF; ?>' method=post><table border=0><tr><td>Name</td><td><input type=text name='Name'>*</td></tr><tr><td>Email</td><td><input type=text name='Email'>*</td></tr></table><input type=submit value='Submit Form' name='submt'> <input type=reset value='Reset Form'></form><? }?>

    Form 2 (to appear on the same page)

    <?php

    if (isset($submt)){


    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    if($Email=="" ){
    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if($errors==1) echo $error;
    else{
    $message="Email: ".$Email."
    ";
    mail("a@a.com","Form Submitted at your website",$message,"From: phpFormGenerator");
    header("Refresh: 0;url=http://www.thinkingshed.com/dev/thanks.html");
    }

    }else{
    ?>
    <form action='<? echo $PHP_SELF; ?>' method=post><table border=0><tr><td>Email</td><td><input type=text name='Email'>*</td></tr></table><input type=submit value='Submit Form' name='submt'> <input type=reset value='Reset Form'></form><? }?>

    And then this would take you to a thanks page and then you would be able to refer a friend to the site with a "your name", "your email", "friends name", "friends email" "text field" and then this would also be bcc'd to me so I know who is sending what to who.

  8. #8
    Join Date
    Jan 2005
    Posts
    446
    so the second form is the "refer your friend form"?

  9. #9
    Join Date
    Apr 2007
    Posts
    30
    no sorry, I haven't included the refer a friend form because I was unsure as to how to do that from the form creator you mentioned earlier. Form 1 & 2 mentioned above are both for the one page.

  10. #10
    Join Date
    Jan 2005
    Posts
    446
    Ok...I took the second form to be the refer form...so we'll have to change that. I suggest you recreate the form with all the fields you want (i.e. from, to, etc) and post the code here and I'll make the changes to bcc you, etc.

    Just upload the files in the attached zip folder...make the required changes in both registration.php and refer.php (but we'll be over writting refer.php once you redo the form)
    Attached Files Attached Files

  11. #11
    Join Date
    Apr 2007
    Posts
    30
    Hi, I've changed the two forms but haven't touched the other pages. They now include all forms that should appear on the two pages. Does this form have any checks to make sure you've a) filled in the required fields and b) submitted a valid email address? Thanks once again

  12. #12
    Join Date
    Apr 2007
    Posts
    30
    Sorry forgot to attach!

  13. #13
    Join Date
    Apr 2007
    Posts
    30
    Sorry I'm losing my mind!
    Attached Files Attached Files

  14. #14
    Join Date
    Jan 2005
    Posts
    446
    try this. remember to go through all the code to make sure that the websites and the email addresses are right. I haven't done any testing so let me know what errors you get.
    Attached Files Attached Files

  15. #15
    Join Date
    Apr 2007
    Posts
    30
    Hi, I've uploaded all the files into the /dev/ directory. You can see the 1st form here: 1st form and 2nd here: 2nd form. I've changed the "your@email.com" to my own email address. The 1st form goes through to the thanks and error pages okay but doesn't send an email to anybody. The 2nd form gives the following error "Parse error: syntax error, unexpected T_STRING in /home/ten2ten/public_html/dev/refer.php on line 22"

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