Thread: PHP form
View Single Post
Old 03-11-2009, 10:41 AM   #1 (permalink)
murdocsvan
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default PHP form

Recently i've been really getting into PHP and have been using W3Schools Online Web Tutorials as tutorials. Now im just experimenting a bit and combining what i know. JUST FOR A LAUGH(not a spambomb) i've made a form which can send out an email to a specified email address. I've also made it so that you can choose what your email address , and you can choose how many it sends.

I've now tried putting in a checkbox which allows the person doing it to randomise the email address it sends from. Howvee rim having loads of trouble trying to get this to work.

This is the HTML form:

Code:
<html>
<body>
<head>
<meta name="robots" content="noindex, nofollow" />
<meta name="robots" content="noarchive" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:.:PHP Practise Work:.:</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<form action="form_result.php" method="post">
Email of recipiant: <input type="text" name="email" /><br />
Email of sender: <input type="text" name="semail" />
<input type="checkbox" name="random" value="random">Random?<br />

Number of emails to send: <input type="text" name="amount" /><br />
<input type="submit" value="Send" />
<input type="reset" value="Reset" />
</form>

</body>
</html>
And this is the form that the data gets sent to, using $_POST:

Code:
<?php

function = randomize()
	{
	if ($_POST["random"]="random")
		return rand(1,8) . "@" . rand(1,5) . ".com";
	else 
		return $_POST["semail"];
	}

$val=1;
while($val<=$_POST["amount"])
	{
	$to = $_POST["email"];
	$subject = "LOL";
	$message = "Ka-Pwned!!";
	$from = randomize();
	$headers = "From: $from";
	mail($to,$subject,$message,$headers);
	$val++;
	}
	
	
echo "Emails sent!";
	
?>
Whenever i've tried it, it submits, but then says it has a problem parsing on the 3rd line.
__________________

murdocsvan is offline