Forum Moderators: coopster

Message Too Old, No Replies

PHP Forms: Required Fields

         

Sutaru

10:35 pm on Sep 5, 2009 (gmt 0)

10+ Year Member



I recently moved my website from a server with PHP4.4.7 to one with PHP 5.2.6. The contact.php action that I was using on my old server no longer works. I've tried rewriting the code, but none of the scripts I've found work. I've read the thread on PHP form basics, and took some code from there, but I'm still getting errors

This is the link to the application: <snip>

This is the code for that application:


<center><form method="POST" action="contact.php" onsubmit=" return formbreeze_sub()" name="form1" >
Character Name<br>
<input type="text" name="name" size="50"><br>
Forum Name<br>
<input type="text" name="forum" size="50"><br>
Jobs and Subjobs. Please indicate your main job(s).<br>
<input type="text" name="jobs" size="50"><br>
Merits<br>
<textarea rows="4" cols="50" name="merits"></textarea><br>
What HNM experience do you have?<br>
<input type="text" name="hnm" size="50"><br>
Please list some of your current gear sets [at least for your main job(s)] and when you choose to use those sets (I.E. Elemental, Enfeebling, MND, STR, Haste, TP, etc). Just give us a general overview.<br>
<textarea rows="4" cols="50" name="gear"></textarea><br>
Do you have sky? (You must have sky for your application to be considered.)<br>
<input type="text" name="sky" size="50"><br>
Do you have Sea? If not, what Mission are you on? (*Please Note: Sea is a requirement to join our LS.)<br>
<input type="text" name="sea" size="50"><br>
Will doing Dynamis with us only, be a problem for you? Dynamis is a required event with this shell. You will not be able to have another dynamis LS. If you do and plan to stay with them, do not bother applying, as your application will be declined. (<b>Hint</b>: Yes is the wrong answer.)<br>
<input type="text" name="dynamis" size="50"><br>
Do you have Dynamis - Xarcabard access?<br>
<input type="text" name="xarcabard" size="50"><br>
Do you have access to Bahamut Version 2?<br>
<input type="text" name="bv2" size="50"><br>
Do you have experience in Einherjar? What feathers do you have?<br>
<input type="text" name="einherjar" size="50"><br>
Your previous LS and why you left. If you wish not to state your reason for leaving, please contact one of the officers in-game<br>
<input type="text" name="previous_ls" size="50"><br>
Why are you interested in joining Empire and how do you think you will help by joining us?<br>
<input type="text" name="why_join" size="50"><br>
Play time (list approximate hours a week you can play, what days/times you are available and your time zone.)<br>
<input type="text" name="playtime" size="50"><br>
Other comments or any other information about yourself that will be helpful in our decision (Be sure to list any high level crafts you have.)<br>
<input type="text" name="other" size="50"><br>
How did you hear about Empire?<br>
<input type="text" name="how" size="50"><br>
Member Reference (Please be specific. "A friend" is not specific. A reference is someone who will vouch for you as a player.)<br>
<input type="text" name="reference" size="50"><br>
<p align="center">CROSS SERVER APPLICATIONS PLEASE ANSWER THE FOLLOWING. IF YOU ARE A CROSS SERVER APPLICANT AND DO NOT FILL OUT THIS AREA OF THE APPLICATION, WE WILL CONSIDER YOUR APPLICATION AS VOIDED</p>
Previous Name<br>
<input type="text" name="prevoius_name" size="50"><br>
Previous Server<br>
<input type="text" name="previous_server" size="50"><br>
Previous Linkshell<br>
<input type="text" name="previous_s_ls" size="50"><br>
Reason for leaving that shell<br>
<input type="text" name="reason_leave" size="50"><br>
Reason for server transfer<br>
<input type="text" name="reason_transfer" size="50"><br>

<p align="center">Please be aware that Server transfers will more than likely have a check on BlueGartr</p>

<input type="submit" value="Submit" name="submit">
</form>
</center>

And this is the contact.php I am using. It's giving me a "page can not be displayed" error:


<?php
$errmsg = "";
if (!isset($_POST['name']) ¦¦ empty($_POST['name'])) $errmsg .= "<p>Please enter your first name";
if (!isset($_POST['forum']) ¦¦ empty($_POST['forum'])) $errmsg .= "<p>Please enter your last name";
if ($errmsg!= "") {
echo $errmsg;
echo "<a href=\"javascript:history.back();\">Please go back and fill out the missing fields</a>";
exit;
} else {

$to = 'email@example.com' . ', ';
$to .= 'email@comcast.net' . ', ';
$to .= 'email@yahoo.com' . ', ';
$to .= 'email@yahoo.com' . ', ';
$to .= 'email@hotmail.com';

$subject = 'New Application';

$message = 'Character Name: $name

Forum Name: $forum

Jobs and Subjobs. Please indicate your main job(s).
$jobs

Merits
$merits

What HNM experience do you have?
$hnm

Please list some of your current gear sets [at least for your main job(s)] and when you choose to use those sets (I.E. Elemental, Enfeebling, MND, STR, Haste, TP, etc). Just give us a general overview.
$gear

Do you have sky? $sky

Do you have sea? $sea

Will doing dynamis with us be a problem for you? $dynamis

Do you have Dynamis - Xarcabard access? $xarcabard

Do you have access to Bahamut Version 2? $bv2

Do you have experience in Einherjar? What feathers do you have? $einherjar

Your previous LS & why you left
$previous_ls

Why are you interested in joining Empire?
$why_join

Play time: $playtime

Other comments or information about yourself that will helpful in our decision (Be sure to list any high level crafts you have.)
$other

How did you hear about Empire?
$how

Member Reference (Please be specific. "A friend" is not specific. A reference is someone who will vouch for you as a player.)
$reference

!=*= Cross server applications =*=!

Previous Name:
$previous_name

Previous Server: $previous_server

Previous Linkshell: $previous_s_ls

Reason for leaving that shell:
$reason_leave

Reason for server transfer:
$reason_transfer';

if (mail($to, $subject, $message)) {
echo "<html>
<head>
<title>Empire Application Sent!</title>
</head>
<body>
<center>
Your application has been submitted.
<br>We will get back to you as soon as possible. Upon approval, you will be put on a two week trial member status.
<br><b><u>Note:</u> Filling out the application is not the same as registering for the forums. Please <a href=\"http://www.example.com\">return to the forums</a> and register if you have not already done so.
<br>REGISTERING FOR THE FORUMS IS REQUIRED!</b>

<p>Empire Officer Team</p>
</center>
</body>
</html>"} else {
echo "<head>
<title>Empire Application Failed to Send.</title>
</head>
<body>
<center>
Your application has not been submitted. Please go back and try submitting again. If problems continue, contact Sutaru in game.</center>
</body>
</html>";
}
}
//"MIME-Version: 1.0\n" . "Content-type: text/php/html; charset=iso-8859-1"
?>

[edited by: dreamcatcher at 11:07 am (utc) on Sep. 7, 2009]
[edit reason] No Urls Please. See TOS. [/edit]

CyBerAliEn

12:08 am on Sep 9, 2009 (gmt 0)

10+ Year Member



Couple of points...

#1... Does your 'contact.php' and HTML form page reside in the same directory level? ie: contact.php and form page are in same directory/folder

They need to be because of your FORM ACTION:

<form method="POST" action="contact.php" onsubmit=" return formbreeze_sub()" name="form1" >

#2... What does the Javascript function, formbreeze_sub(), do? If it determines where to submit your form to, that could be your problem.

#3... Look at your 'message' variable in 'conact.php', example:

$message = 'Character Name: $name

Forum Name: $forum

Jobs and Subjobs. Please indicate your main job(s).
$jobs

Note that because this variable is a SINGLE QUOTE instead of a DOUBLE QUOTE, all of the variables inside this var will not be evaluated by PHP!

That is all I quickly noticed.

rocknbil

3:36 am on Sep 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



but I'm still getting errors

Welcome aboard Sutaru, in addition to the previous post which may fix a lot, what is the source of your errors (Javascript, PHP) and what are the errors specifically?