Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1535 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

PHP Form

Thread title: PHP Form
Closed Thread    
    Thread tools Search this thread Display Modes  
12-07-2006, 08:07 PM
#1
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old  PHP Form

EDITED

Anyone/Everyone,

Can anyone help me to locate a php form for a competition I am running.

I need people to be able to pick an answer to a question (radio buttons) and then input their details (Address Line 1, Address Line 2, City, Postal Code, E-mail address and Full name) then a tick box to have them subscribe to my newsletter.

I have a code for a newsletter sign up for, that I was trying to modify but I have failed. Boo Hoo.


Can anyone help me? Perhaps even just to assist me in modifying the code I already have?



Code:
<?php
function pageRefreshed(){
  if($_SERVER['HTTP_CACHE_CONTROL'] == 'max-age=0')
     return true;

   return false;
}
$mailType2Checked = " checked=\"checked\"";
$mailEmail = "Email Address";
if ((!pageRefreshed()) && ($_POST['s'] == 1)) {
	$valid = true;

	$mailEmail = trim(htmlspecialchars($_POST['mailEmail']));
	$mailType = intval($_POST['mailType']);
	
	$mailType1Checked = $mailType2Checked = "";
	switch ($mailType) {
		case 1: $mailType = "Text"; $mailType1Checked = " checked=\"checked\""; break;
		case 2: $mailType = "HTML"; $mailType2Checked = " checked=\"checked\""; break;
		default: $mailType = ""; $mailType2Checked = " checked=\"checked\""; break;
	}
	
	if(empty($mailEmail) || empty($mailType)){
		$valid = false;
		$mailErr = "One or more of the fields were left blank. Please make sure you have filled out the form completely.";
	} else {
		//valid characters...
		$_name = "/^[-!#$%&*+\\.\/0-9=?A-Z^_`{|}~]+";
		$_host = "([-0-9A-Z]+\.)+";
		$_tlds = "([0-9A-Z]){2,4}$/i";
		if (!preg_match($_name."@".$_host.$_tlds,$mailEmail)){
			$mailErr = "The email address you supplied is invalid. Please supply a valid email address.";
			$valid = false;
		}
	}
	
	$divstyle = "";
	
	if($valid){
		$divstyle = " style=\"display:none;\"";
		$to = "your@emailhere.com";
		//$to = "you@example.com";
		$re = "New Mailing List Subscriber: $mailEmail $mailType";
		//add From: header
		$headers = "From: MadGamers System\r\n";
		//specify MIME version 1.0
		$headers .= "MIME-Version: 1.0\r\n";
		//unique boundary
		$boundary = uniqid("omgwtfbbq");
		//tell e-mail client this e-mail contains alternate versions
		$headers .= "Content-Type: multipart/alternative" . "; boundary = $boundary\r\n\r\n";
		//message to people with clients who don't understand MIME
		$headers .= "This is a MIME encoded message.\r\n\r\n";
		//plain text version of message
		$headers .= "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
		$headers .= chunk_split(base64_encode("A visitor has requested that their email address ($mailEmail) be added to the mailing list. They would like to receive $mailType emails."));
		//HTML version
		$headers .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n";
		$headers .= chunk_split(base64_encode("A visitor has requested that their email address ($mailEmail) be added to the mailing list. They would like to receive $mailType emails."));
		//send message
		mail($to, $re, "", $headers);
		$mailSuccess = "Your email address has been successfully added to our newsletter, thank you for your interest.";
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Join our newsletter!</title>
</head>

<body>
<?php echo $mailErr; ?>
<div<?php echo $divstyle; ?>>
<form method="post">
<table width="">
	<tr>
		<td colspan="5">Please enter your email address and select the<br />format you would like to receive our newsletter in:</td>
	</tr>
	<tr>
		<td><input type="text" name="mailEmail" value="<?php echo $mailEmail; ?>" onclick="this.select();" /></td>
		<td><input type="radio" name="mailType" value="1"<?php echo $mailType1Checked; ?> /></td><td>Text</td>
		<td><input type="radio" name="mailType" value="2"<?php echo $mailType2Checked; ?> /></td><td>HTML</td>
	</tr>
	<tr>
		<td align="center" colspan="5"><input type="hidden" name="s" value="1" /><input type="submit" value="Submit" /></td>
	</tr>
</table>
</form>
</div>
<?php echo $mailSuccess; ?>
</body>
</html>
Is anyone able to help me ammend this to have the following fields for a competition submission form? I can't seem to get it to send when I do edit it.

Answer 1 (radio button)
Answer 2 (radio button)
Answer 3 (radio button)

E-mail address (text field)

Full Name (text field)

Address Line 1 (text field)
Address Line 2 (text field)
Town/City (text field)
Postal Code (text field)

Newsletter signup (yes/no - tickbox)

I had trouble with the functions, not with the form itself. If anyone is able to help I appreciate it.

12-07-2006, 08:29 PM
#2
Jeff Andersen is offline Jeff Andersen
Status: Superstar
Join date: Apr 2005
Location:
Expertise:
Software:
 
Posts: 4,449
iTrader: 10 / 100%
 

Jeff Andersen is on a distinguished road

  Old

Can you link to the competition?

12-07-2006, 09:03 PM
#3
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old

It is not up and running, but the page it will be visible on is:

http://www.madgamers.net/competition.php

12-09-2006, 07:49 PM
#4
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old

Please, someone must be able to help me!

12-09-2006, 08:04 PM
#5
Dream is offline Dream
Dream's Avatar
Status: Lewis Ainslie
Join date: Dec 2005
Location: UK, England.
Expertise:
Software:
 
Posts: 1,630
iTrader: 15 / 100%
 

Dream is on a distinguished road

Send a message via MSN to Dream

  Old

http://www.hotscripts.com/search/13195482.html

Something like a poll script?

12-09-2006, 10:18 PM
#6
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old

It's not a poll I need, I need something that will allow poeple to answer a multiple choice question, and submit their personal details to allow me to post their prizes.

12-11-2006, 08:31 PM
#7
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old

I have edited the first post with a copy of the script I was using.

12-11-2006, 10:24 PM
#8
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

I may be able to write you one. I'll see when I have some free time.

12-12-2006, 04:18 PM
#9
scrappy is offline scrappy
scrappy's Avatar
Status: Member
Join date: Aug 2006
Location: Newcastle upon Tyne
Expertise:
Software:
 
Posts: 172
iTrader: 1 / 100%
 

scrappy is on a distinguished road

Send a message via MSN to scrappy

  Old

That would be great. I really appreciate that.

12-12-2006, 10:27 PM
#10
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Do you want this all on one page?

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed