Hey, I'm trying to get a form submit to work, I've got this made:


<?php
$to = "xxx@xxx.xxx" ;
$subject = "Application form" ;
$firstname = $_REQUEST ;
$charname = $_REQUEST ;
$class = $_REQUEST ;
$level = $_REQUEST ;
$age = $_REQUEST ;
$timezone = $_REQUEST ;
$raidavail = $_REQUEST ;
$mmoexp = $_REQUEST ;
$charlink = $_REQUEST ;
$s2_q1 = $_REQUEST ;
$s2_q2 = $_REQUEST ;
$s2_q3 = $_REQUEST ;
$s2_q4 = $_REQUEST ;
$s2_q5 = $_REQUEST ;
$s2_q6 = $_REQUEST ;
$s2_q7 = $_REQUEST ;
$s2_q8 = $_REQUEST ;
$s3_q1 = $_REQUEST ;
$s3_q2 = $_REQUEST ;
$s3_q3 = $_REQUEST ;
$s3_q4 = $_REQUEST ;
$s3_q5 = $_REQUEST ;
$s3_q6 = $_REQUEST ;
$s3_q7 = $_REQUEST ;
$headers = "From: $charname" ;

$sent = mail($to, $subject, $firstname, $charname, $class, $level, $age, $timezone, $raidavail, $mmoexp, $charlink, $s2_q1, $s2_q2, $s2_q3, $s2_q4, $s2_q5, $s2_q6, $s2_q7, $s2_q8, $s3_q1, $s3_q2, $s3_q3, $s3_q4, $s3_q5, $s3_q6, $s3_q7, $headers) ;

if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

When it submits, I get this error:

Warning: mail() expects at most 5 parameters, 27 given in /home/content/v/a/l/valthonic/html/submitform.php on line 30

Looking over previous posts. I don't see any issue with it, someone posted this exact layout I just added to it, and its not working.. Anyone have a helpful tip to fix this?

Thank you.

I think instead of:

$sent = mail($to, $subject, $firstname, $charname, $class, $level, $age, $timezone, $raidavail, $mmoexp, $charlink, $s2_q1, $s2_q2, $s2_q3, $s2_q4, $s2_q5, $s2_q6, $s2_q7, $s2_q8, $s3_q1, $s3_q2, $s3_q3, $s3_q4, $s3_q5, $s3_q6, $s3_q7, $headers) ;

You want

$sent = mail($to, $subject, $firstname . $charname . $class . $level .  $age. $timezone . $raidavail . $mmoexp . $charlink . $s2_q1 .  $s2_q2 . $s2_q3 . $s2_q4 . $s2_q5 . $s2_q6 .  $s2_q7 .  $s2_q8 .  $s3_q1 . $s3_q2 .  $s3_q3 . $s3_q4 .  $s3_q5 . $s3_q6 . $s3_q7, $headers) ;

Notice that between $firstname and $s3_q7 , I used the '.' operator (which concatenates the variables), rather than a comma.

This is because the prototype for the function mail looks like this (as you're attempting to use it):

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

Note that this will send some REALLY ugly looking messages, unless your variables already have spaces and formatting in them (i doubt it :P)

Hey thank you, that got my post to actually POST, and send me an email. the problem is. I got this as my email:

TestTestGladiator2020CSTHighhttp://www.kath.us33333333TestTestTestTestTestTestTest

My form, I made an HTML page just so you can view it. hopefully you can tell me what I did wrong with it..

www.kath.us/form.html

The problem is that all your variables are being sent as one concatenated string. You need to put spaces/other formatting in between them, to create a better looking output. For example, the following will send 'First Name: and then everything else on a line by itself.

$sent = mail($to, $subject, $firstname . ': \n' .  $charname . '\n' . $class  . '\n' . $level  . '\n' . $age . '\n' . $timezone  . '\n' . $raidavail  . '\n' . $mmoexp  . '\n' . $charlink  . '\n' . $s2_q1  . '\n' . $s2_q2  . '\n' . $s2_q3  . '\n' . $s2_q4  . '\n' . $s2_q5  . '\n' . $s2_q6  . '\n' . $s2_q7  . '\n' . $s2_q8  . '\n' . $s3_q1  . '\n' . $s3_q2  . '\n' . $s3_q3  . '\n' . $s3_q4  . '\n' . $s3_q5  . '\n' . $s3_q6  . '\n' . $s3_q7, $headers) ;

By the way, you really should put the message into a variable, to make your code more readable (personal opinion)
so:

$message = $firstname . ': \n' .  $charname . '\n' . $class  . '\n' . $level  . '\n' . $age . '\n' . $timezone  . '\n' . $raidavail  . '\n' . $mmoexp  . '\n' . $charlink  . '\n' . $s2_q1  . '\n' . $s2_q2  . '\n' . $s2_q3  . '\n' . $s2_q4  . '\n' . $s2_q5  . '\n' . $s2_q6  . '\n' . $s2_q7  . '\n' . $s2_q8  . '\n' . $s3_q1  . '\n' . $s3_q2  . '\n' . $s3_q3  . '\n' . $s3_q4  . '\n' . $s3_q5  . '\n' . $s3_q6  . '\n' . $s3_q7;

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

Ohhh, ok, thanks, I'll try that, and I'll try your suggestion first even.

Hmm.. I did what you said, I put in your bottom suggestion, and I got this error:
Parse error: syntax error, unexpected T_VARIABLE in /home/content/v/a/l/valthonic/html/submitform.php on line 57

Can you post the entire code so that we can tell what is wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.