Click to See Complete Forum and Search --> : 2 scripts on the same page?
greencode
04-19-2007, 09:36 AM
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!
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
greencode
04-20-2007, 05:06 PM
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.
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
greencode
04-22-2007, 05:29 PM
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)
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:
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.
greencode
04-23-2007, 08:26 AM
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.
so the second form is the "refer your friend form"?
greencode
04-23-2007, 09:36 AM
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.
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)
greencode
04-23-2007, 10:59 AM
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
greencode
04-23-2007, 11:01 AM
Sorry forgot to attach!
greencode
04-23-2007, 11:02 AM
Sorry I'm losing my mind!
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.
greencode
04-23-2007, 12:49 PM
Hi, I've uploaded all the files into the /dev/ directory. You can see the 1st form here: 1st form (http://thinkingshed.com/dev/competition-and-newsletter-form.php) and 2nd here: 2nd form (http://thinkingshed.com/dev/refer-form.php). 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"
ok...for the refer.php try changing the last two lines of $header to:
$headers .= 'Cc: ' .$YourEmail . $eol;
$headers .= 'Bcc: ' .$fromaddress . $eol;
Does the newsletter one send an email?
also, depending on what email address you are using, there is a very good chance that these emails will get stuck in your spam box
greencode
04-23-2007, 01:06 PM
Still no emails get sent, and no none of them send an email. So that's competition & newsletter on the 1st form and refer on the 2nd
i'll have to work on it. I'll get back to you
try this. I have done some testing but not very much. Make sure you change the top of every file that does not end with -form.php
The emailing worked for me, but you HAVE to use an email address that comes from the domain you are sending the email from. So the emails from these forms have to originate from an email address that ends in the domain were the form resides. In your case this would be: any-email-address@thinkingshed.com Also, the emails get caught in the spam folder of hotmail...but they are being sent.
You'll also have to change the path to the scripts in the files that do end with -form.php (i.e. change the <form action = "path/to/script.php"> so that it's right)
Let me know what errors you get.
Cheers,
Sae
did you manage to get this to work?