Jump to content

php form error


Boxerman

Recommended Posts

Hi guys!

 

i need help with this script,

 

this is the code:

 

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ; 
  $subject = "Job Application" ;
  $firstname = $_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $age = $_REQUEST['age'] ;
  $reason = $_REQUEST['reason'] ;
  $timezone = $_REQUEST['timezone'] ;
  $times = $_REQUEST['times'] ;
  mail( "boxerman@uksbestsite.com", "Subject: $subject",
  $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" );
  echo "Thank you for applying!, please allow upto 24 hours for reply!";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='djapp.php'>
  First Name: <input name='firstname' type='text' /><br />
  Last Name: <input name='lastname' type='text' /><br />
  Email: <input name='email' type='text' /><br />
  Age: <input name='age' type='text' /><br />
  Time Zone: <input name='timezone' type='text' /><br />
  Times Can DJ: <input name='times' type='text' /><br />
  Reason for applying:<br />
  <textarea name='message' rows='10' cols='40' />

  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

 

 

 

when sending i get this :(

 

Warning: mail() expects at most 5 parameters, 9 given in /home/nonstopr/public_html/djapp.php on line 245

 

line 245 is in th e script above but to help the line is

 

  $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" );

 

thanks guys!

Link to comment
Share on other sites

mail( "boxerman@uksbestsite.com", "Subject: $subject",  $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" );

 

I think you're using the mail() function not correctly.

 

PHP.NET

<?php

$to      = 'nobody@example.com';

$subject = 'the subject';

$message = 'hello';

$headers = 'From: webmaster@example.com' . "\r\n" .

    'Reply-To: webmaster@example.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

 

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

?>

JaZz

Link to comment
Share on other sites

ok im confused, do i need to declare $message  then add the $firstname $lastname etc?

 

Like:

 

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ; 
  $subject = "Job Application" ;
  $firstname = $_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $age = $_REQUEST['age'] ;
  $reason = $_REQUEST['reason'] ;
  $timezone = $_REQUEST['timezone'] ;
  $times = $_REQUEST['times'] ;


$to      = $email;
$subject = $subject;

$message = $firstname."\n";
$message .= $lastname."\n";
$message .= $reason."\n";
$message .= $timezone."\n";
$message .= $times."\n";

$headers = 'From: boxerman@uksbestsite.com' . "\r\n" .
    'Reply-To: boxerman@uksbestsite.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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


  echo "Thank you for applying!, please allow upto 24 hours for reply!";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='djapp.php'>
  First Name: <input name='firstname' type='text' /><br />
  Last Name: <input name='lastname' type='text' /><br />
  Email: <input name='email' type='text' /><br />
  Age: <input name='age' type='text' /><br />
  Time Zone: <input name='timezone' type='text' /><br />
  Times Can DJ: <input name='times' type='text' /><br />
  Reason for applying:<br />
  <textarea name='message' rows='10' cols='40' />

  </textarea><br />
  <input type='submit' />
  </form>";
  }

?>

 

JaZz

Link to comment
Share on other sites

Ok that emails me but doesnt show all of the fields?

 

 

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ; 
  $subject = "Job Application" ;
  $firstname = $_REQUEST['firstname'] ;
  $lastname = $_REQUEST['lastname'] ;
  $email = $_REQUEST['email'] ;
  $age = $_REQUEST['age'] ;
  $reason = $_REQUEST['reason'] ;
  $timezone = $_REQUEST['timezone'] ;
  $times = $_REQUEST['times'] ;


$to      = "boxerman@uksbestsite.com";
$subject = $subject;

$message = $firstname."\n";
$message .= $lastname."\n";
$message .= $email."\n";
$message .= $reason."\n";
$message .= $timezone."\n";
$message .= $times."\n";

$headers = 'From: boxerman@uksbestsite.com' . "\r\n" .
    'Reply-To: boxerman@uksbestsite.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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


  echo "Thank you for applying!, please allow upto 24 hours for reply!";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='djapp.php'>
  First Name: <input name='firstname' type='text' /><br />
  Last Name: <input name='lastname' type='text' /><br />
  Email: <input name='email' type='text' /><br />
  Age: <input name='age' type='text' /><br />
  Time Zone: <input name='timezone' type='text' /><br />
  Times Can DJ: <input name='times' type='text' /><br />
  Reason for applying:<br />
  <textarea name='message' rows='10' cols='40' />

  </textarea><br />
  <input type='submit' />
  </form>";
  }

?>

Link to comment
Share on other sites

try using $_POST instead of $_REQUEST

 

i've attached an interesting email/form script

maybe it will be of some kind of help.

 

Let me know if you have any questions about it

Cheers.

 

[attachment deleted by admin]

Link to comment
Share on other sites

<?php
if ($_POST['submit']==true)
//if "email" is filled out, send email
  {
  //send email
  $email = $_POST['email'] ; 
  $subject = "Job Application" ;
  $firstname = $_POST['firstname'] ;
  $lastname = $_POST['lastname'] ;
  $email = $_POST['email'] ;
  $age = $_POST['age'] ;
  $reason = $_POST['reason'] ;
  $timezone = $_POST['timezone'] ;
  $times = $_POST['times'] ;


$to      = "boxerman@uksbestsite.com";
$subject = $subject;



$message .="\n";
$message .= $firstname."\n";
$message .= $lastname."\n";
$message .= $email."\n";
$message .= $reason."\n";
$message .= $timezone."\n";
$message .= $times."\n";

$headers ='From: boxerman@uksbestsite.com' . "\r\n" .
    'Reply-To: boxerman@uksbestsite.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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


  echo "Thank you for applying!, please allow upto 24 hours for reply!";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action=''djapp.php'>
  First Name: <input name='firstname' type='text' /><br />
  Last Name: <input name='lastname' type='text' /><br />
  Email: <input name='email' type='text' /><br />
  Age: <input name='age' type='text' /><br />
  Time Zone: <input name='timezone' type='text' /><br />
  Times Can DJ: <input name='times' type='text' /><br />
  Reason for applying:<br />
  <textarea name='message' rows='10' cols='40' />

  </textarea><br />
  <input type='hidden' name='submit' value='true' />
  <input type='submit' value='Submit' />
  </form>";
  }

?>

 

 

I've tested it on my server and it works fine. HERE

You needed to have a form (hidden value) that let the form know when to start sending...

Link to comment
Share on other sites

sure!

 

$message .= "Age: $age\n";

or keep the next line inticator separate to have a cleaner code:

$message .= "\n";

 

\n is equivalent to br (just so you know)

 

 

Happy Coding! ;)

 

 

LE: I'd really advise to take a look at the script i attached in the earlyer post... it will explane allot ;)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.