PDA

View Full Version : Application [HELP]



HabbDance
24-11-2008, 11:51 PM
Ok, first off, I'm new to PHP. I am sure this is all horribly wrong so don't yell at me or say something like 'FAIL GTFO' :P

Can someone just look this over and tell me if it will work and how to fix it?

BTW, I'm sure the $to variable is wrong



<!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" xml:lang="en">
<head>
<title>Job Application</title>
<style type="text/css">
<!--
body {
font-family: tahoma;
font-size: 11px;
font-weight: bold;
-->
</style>
</head>
<body>
<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="button" id="button" value="Submit" />

</form>';

} else {

$headers .= 'To: Me <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";

$subject = '$_POST[ 'habbo' ] - Job Application';

$to = $_POST[ 'email' ];
$message = $_POST[ 'name' ] <br /> $_POST[ 'age' ] <br /> $_POST[ 'habbo' ] <br /> $_POST[ 'job' ] <br /> $_POST[ 'experience' ] <br /> $_POST[ 'message' ];

mail($to, $subject, $message, $headers);

}
?>
</body>
</html>
Thanks.

PS - I got the original script from another thread so credit to whoever posted it ;)

EDIT: tested it and it says this:

Parse error: syntax error, unexpected T_STRING in /homepages/34/d237406810/htdocs/wsb4850525601/form_test.php on line 34

Line 34: $subject = '$_POST[ 'habbo' ] - Job Application';

Joe!
25-11-2008, 12:18 AM
Try this
<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="button" id="button" value="Submit" />

</form>';

} else {

$headers .= 'To: Me <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";

$subject = "".$_POST[ 'habbo' ]." - Job Application";

$to = $_POST[ 'email' ];
$message = "".$_POST[ 'name' ]." <br /> ".$_POST[ 'age' ]." <br /> ".$_POST[ 'habbo' ]." <br /> ".$_POST[ 'job' ]." <br /> ".$_POST[ 'experience' ]." <br /> ".$_POST[ 'message' ]."";

mail($to, $subject, $message, $headers);

}

?>

Excellent2
25-11-2008, 12:22 AM
<!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" xml:lang="en">
<head>
<title>Job Application</title>
<style type="text/css">
<!--
body {
font-family: tahoma;
font-size: 11px;
font-weight: bold;
-->
</style>
</head>
<body>
<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="button" id="button" value="Submit" />

</form>';

} else {

$headers .= 'To: Me <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";

$subject = "$_POST[ 'habbo' ] - Job Application";

$to = $_POST[ 'email' ];
$message = $_POST[ 'name' ] <br /> $_POST[ 'age' ] <br /> $_POST[ 'habbo' ] <br /> $_POST[ 'job' ] <br /> $_POST[ 'experience' ] <br /> $_POST[ 'message' ];

mail($to, $subject, $message, $headers);

}
?>
</body>
</html>
Should work.

HabbDance
25-11-2008, 12:22 AM
Try this
<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="button" id="button" value="Submit" />

</form>';

} else {

$headers .= 'To: Me <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";

$subject = "".$_POST[ 'habbo' ]." - Job Application";

$to = $_POST[ 'email' ];
$message = "".$_POST[ 'name' ]." <br /> ".$_POST[ 'age' ]." <br /> ".$_POST[ 'habbo' ]." <br /> ".$_POST[ 'job' ]." <br /> ".$_POST[ 'experience' ]." <br /> ".$_POST[ 'message' ]."";

mail($to, $subject, $message, $headers);

}

?>
Thanks, that made the form appear +rep

But it doesnt send to me and I think I know why.



$to = $_POST[ 'email' ];


I have no 'email' field :O

Joe!
25-11-2008, 12:35 AM
just change to
$to = "[email protected]" i guess thats where you want the email sent to?

HabbDance
25-11-2008, 12:40 AM
just change to
$to = "[email protected]" i guess thats where you want the email sent to?
no, didn't work. :(

Joe!
25-11-2008, 12:43 AM
hmm try this:

<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="submit" id="submit" value="Submit" />

</form>';

} else {

$subject = "".$_POST[ 'habbo' ]." - Job Application";

$to = "[email protected]";
$message = "".$_POST[ 'name' ]." <br /> ".$_POST[ 'age' ]." <br /> ".$_POST[ 'habbo' ]." <br /> ".$_POST[ 'job' ]." <br /> ".$_POST[ 'experience' ]." <br /> ".$_POST[ 'message' ]."";

mail($to, $subject, $message);

}

?>
Put the headers back in if you like, I just realised I got rid of them lol. Bed is calling.

HabbDance
25-11-2008, 12:49 AM
hmm try this:

<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="submit" id="submit" value="Submit" />

</form>';

} else {

$subject = "".$_POST[ 'habbo' ]." - Job Application";

$to = "[email protected]";
$message = "".$_POST[ 'name' ]." <br /> ".$_POST[ 'age' ]." <br /> ".$_POST[ 'habbo' ]." <br /> ".$_POST[ 'job' ]." <br /> ".$_POST[ 'experience' ]." <br /> ".$_POST[ 'message' ]."";

mail($to, $subject, $message);

}

?>Put the headers back in if you like, I just realised I got rid of them lol. Bed is calling.
AHA YOUR A LIFE SAVER :D!!!!@! THANKS SO MUCH.
+repped


Also, how would I recieve a file (<input type="file"></input>)

Hypertext
25-11-2008, 02:03 AM
<?php

if( ! $_POST[ 'submit' ] ) {
?>
<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="submit" id="submit" value="Submit" />

</form>
<?php
} else {

$subject = "".$_POST[ 'habbo' ]." - Job Application";

$to = "[email protected]";
$message = "".$_POST[ 'name' ]." <br /> ".$_POST[ 'age' ]." <br /> ".$_POST[ 'habbo' ]." <br /> ".$_POST[ 'job' ]." <br /> ".$_POST[ 'experience' ]." <br /> ".$_POST[ 'message' ]."";

mail($to, $subject, $message);

}

?>

Jackboy
25-11-2008, 08:02 AM
if hypertexts dont work it'll be summin to do with the form.

action = "" could be changed to action = "$PHP_SELF"

Dunno if it'll make a dif ;)

Decode
25-11-2008, 08:23 AM
<!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" xml:lang="en">
<head>
<title>Job Application</title>
<style type="text/css">
<!--
body {
font-family: tahoma;
font-size: 11px;
font-weight: bold;
-->
</style>
</head>
<body>
<?php

if( ! $_POST[ 'submit' ] ) {
echo '<form action="" method="post">
Real Name:<br /><input type="text" name="name" /><br />
Age:<br /><input type="text" name="age" /><br />
Habbo Name:<br /><input type="text" name="habbo" /><br />
Job Applying For:<br /><input type="text" name="job" /><br />
Experience:<br /><textarea rows="2" cols="20" name="experience"></textarea><br />
Message:<br /><textarea rows="2" cols="20" name="message"></textarea><br />
<input type="submit" name="button" id="button" value="Submit" />

</form>';

} else {

$headers .= 'To: Me <[email protected]>' . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";

$subject = $_POST[ 'habbo' ] . ' - Job Application';

$to = $_POST[ 'email' ];
$message = $_POST[ 'name' ] ."<br />". $_POST[ 'age' ] ."<br />". $_POST[ 'habbo' ] ."<br />". $_POST[ 'job' ] ."<br />". $_POST[ 'experience' ] ."<br />". $_POST[ 'message' ];

mail($to, $subject, $message, $headers);

}
?>
</body>
</html>
Easy mystake ;)

HabbDance
25-11-2008, 11:46 AM
Lol, forgot to say I got it, thanks to all :D

Want to hide these adverts? Register an account for free!