Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form weirdness..or stupidity 2

Status
Not open for further replies.

CGIMana

IS-IT--Management
Mar 6, 2006
56
US
Hello, I made a guild applictaion for World of Warcraft, and am confused about two things.

for class, If someone selects a option other then Mage or Palidin, I want them echo'd
Sorry but we aren't recruiting $_POST(class)s at this time

but the if statement isn't working, I just get errors about the end where the e-mail is sent.

Also a very weird thing. If in the free hand answers, or even my select answers contain a ' it's replaced with a / in the post feature. How do I make so it stops doing that?

here's the code for my sendmail.php if the code for the form is needed let me know pls

<html>
<head>
<meta http-equiv="Ascensio; guild; world of warcraft; world of warcrack; wow; guilds; massive multiplayer online role playing games; addiction; community; mmorpg; mmorpgs; mmorpg's" content="text/html; charset=iso-8859-1" />
<title>Ascensio Guild Recruitment</title>
</head>
<body bgcolor="#05475f">
<center>
<table width="770" border="1" bgcolor="CCCCCC" >
<tr>
<td>
<?php
--------------added to show what I put in------------------
if (class="warrior")
if (class="hunter")
echo "Sorry but we aren't recruiting $_POST(class)s at this time."
{ else }
---------------------end of what I added-------------------
echo "Thank you, $_POST[char], for your request. It has been sent to 5 of 11 council members for review, you will be contacted either in game or by e-mail.</p>
<p>The information you inputted was:<br>
Charater Requesting: $_POST[char]<br>
Voucher: $_POST[voucher]<br>
LVL: $_POST[lvl] Class: $_POST[class]<br>
Build: $_POST[build]<br>
Contact E-Mail: $_POST<br>
(only used to contact you for recruitment reasons)<br>
CTPORFILE Link: $_POST[ctprofile]<br>
Professioin 1-$_POST[pro1] Profession 2-$_POST[pro2]<br>
Atunements:
Molten Core- $_POST[mc]<br>
Ony-$_POST[ony]<br>
Blackwing Lair-$_POST[bwl]<br>
Nax-$_POST[nax]<br>
Vent/mod/add-on Requirements: $_POST[will]<br>
Unbuffed Resists:
Arcane:$_POST[arcane]<br>
Fire:$_POST[fire]<br>
Nature:$_POST[nature]<br>
Frost:$_POST[frost]<br>
Shadow:$_POST[shadow]<br>
About you: $_POST[about]<br>
Why Ascensio: $_POST[whyus]<br>
Old Guild 1: $_POST[og1]<br>
Old Guild 2: $_POST[og2]<br>
Old Guild 3: $_POST[og3]<br>
Reason for leaving each: $_POST[ogreason]<br>
What wait for 5 sunders means to me:<br> $_POST[sunder]<br>
RAID Atten weekly: $_POST[week]<br>
Randomness: $_POST[randomness]<br>
Path Clearing: $_POST[pathdestroy]";
//start building the mail string
$msg = "The information for $_POST[char]
Voucher: $_POST[voucher]
LVL: $_POST[lvl]
Class: $_POST[class]
Build: $_POST[build]
Contact E-Mail: $_POST[email]
(only use for contact for recruitment reasons do not post in forums)
CTPROFILE Link: $_POST[ctprofile]
Profession 1-$_POST[pro1] ----- Profession 2-$_POST[pro2]
Attunements:
Molten Core-$_POST[mc]
Ony-$_POST[ony]
Blackwing Lair-$_POST[bwl]
Nax-$_POST[nax]
Vent/mod/add-on Requirements: $_POST[will]
Unbuffed Resists:
Arcane:$_POST[arcane]
Fire:$_POST[fire]
Nature:$_POST[nature]
Frost:$_POST[frost]
Shadow:$_POST[shadow]
About you: $_POST[about]
Why Ascensio: $_POST[whyus]
Old Guild 1: $_POST[og1]
Old Guild 2: $_POST[og2]
Old Guild 3: $_POST[og3]
Reason for leaving each: $_POST[ogreason]
What wait for 5 sunders means to me: $_POST[sunder]
RAID Atten weekly: $_POST[week]
Randomness: $_POST[randomness]
Path Clearing: $_POST[pathdestroy]";
//set up the mail
$recipient = "took out the e-mail addresses";
$subject = "Guild Entry for $_POST[char], $_POST[class]";
$mailheaders = "From: Ascensio App form";
$mailheaders = "Reply-To: cgimana@adelphia.net";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</td>
</tr>
</table>

</center>
</body>
</html>

-Hoped I helped. Don't forget this site is Member supported.
 
Well first oif all all variables in PHP must be preceded with a "$" dollar sign. So your variables should be $class not just class. Also since you are comparing stuff from a form, you should be checking for $_POST['class'] not just class

Second when doing comparisons in an if statement. the correct form is : if(something[red]==[/red]somethingelse).

Notice the 2 equals sign in the comparison.

So your if statement should look like:
Code:
if(($_POST['class']=="warrior")||($_POST['class']=="hunter"){
do something.
else{
echo "..."

}

That translates to If the $_POST['class'] equals hunter or warrior then dop something,
otherwise echo "sorry we are not rtecruiting"....



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi,
stripslashes is what you're looking for to escape the escape slash i.e.
Code:
$variable = stripslashes($_POST[postdata]);


Reality is built on a foundation of dreams.
 
So overyde I just add that line in the php before the if statements and after the <?php so that it'll stop doing that?

vacunita-
I added that code. I'm getting
Parse error: syntax error, unexpected T_ECHO in D:\xampp\xampp\htdocs\sendmail.php on line 15

Line 15 is the first echo: (how do you do that CODE thing that puts the code in it's own little box?)
<?php
if(($_POST['class']=="Warrior")||($_POST['class']=="Hunter")||($_POST['class']=="Rogue")||($_POST['class']=="Priest")||($_POST['class']=="Warlock")||($_POST['class']=="Druid")
echo "Sorry, but we are currently at our max compasity for your class. Your application will still be sent and looked over, however, we may not have a spot for you.<br><br>
The information you inputted was:<br>
Charater Requesting: $_POST[char]<br>
Voucher: $_POST[voucher]<br>
Charaters Level: $_POST[lvl] Class: $_POST[class]<br>
Build: $_POST[build]<br>
Contact E-Mail: $_POST<br>
(only used to contact you for recruitment reasons)<br>
CTPORFILE Link: $_POST[ctprofile]<br>
Profession 1-$_POST[pro1]<br>
Profession 2-$_POST[pro2]<br>
Atunements:<br>
Molten Core- $_POST[mc]<br>
Onyxia's Lair-$_POST[ony]<br>
Blackwing Lair-$_POST[bwl]<br>
Naxxramas-$_POST[nax]<br>
Vent/mod/add-on Requirements: $_POST[will]<br>
Unbuffed Resists:<br>
Arcane:$_POST[arcane]<br>
Fire:$_POST[fire]<br>
Nature:$_POST[nature]<br>
Frost:$_POST[frost]<br>
Shadow:$_POST[shadow]<br>
About you: $_POST[about]<br>
Why Ascensio: $_POST[whyus]<br>
Old Guild 1: $_POST[og1]<br>
Old Guild 2: $_POST[og2]<br>
Old Guild 3: $_POST[og3]<br>
Reason for leaving each: $_POST[ogreason]<br>
What wait for 5 sunders means to me:<br> $_POST[sunder]<br>
RAID Atten weekly: $_POST[week]<br>
Randomness: $_POST[randomness]<br>
Path Clearing: $_POST[pathdestroy]";
//start building the mail string
$msg = "The information for $_POST[char]
Voucher: $_POST[voucher]
Charaters Level: $_POST[lvl]
Class: $_POST[class]
Build: $_POST[build]
Contact E-Mail: $_POST[email]
(only use for contact for recruitment resons do not post in forums)
CTPROFILE Link: $_POST[ctprofile]
Professioin 1-$_POST[pro1] -----Profession 2-$_POST[pro2]
Attunement: Molten Core-$_POST[mc]/Onyxia's Lair-$_POST[ony]/Blackwing Lair-$_POST[bwl]/Naxxramas-$_POST[nax]
Vent/mod/add-on Requirements: $_POST[will]
Unbuffed Resists:
Arcane:$_POST[arcane]
Fire:$_POST[fire]
Nature:$_POST[nature]
Frost:$_POST[frost]
Shadow:$_POST[shadow]
About you: $_POST[about]
Why Ascensio: $_POST[whyus]
Old Guild 1: $_POST[og1]
Old Guild 2: $_POST[og2]
Old Guild 3: $_POST[og3]
Reason for leaving each: $_POST[ogreason]
What wait for 5 sunders means to me: $_POST[sunder]
RAID Atten weekly: $_POST[week]
Randomness: $_POST[randomness]
Path Clearing: $_POST[pathdestroy]";
//set up the mail
$recipient = "removed";
$subject = "Guild Entry for $_POST[char], $_POST[class]";
$mailheaders = "From: Ascensio App form";
$mailheaders = "Reply-To: cgimana@adelphia.net";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}else{
echo "Thank you, $_POST[char], for your request. It has been sent to 5 of 11 council members for review, you will be contacted either in game or by e-mail.</p>
<p>The information you inputted was:<br>
Charater Requesting: $_POST[char]<br>
Voucher: $_POST[voucher]<br>
Charaters Level: $_POST[lvl] Class: $_POST[class]<br>
Build: $_POST[build]<br>
Contact E-Mail: $_POST[email]<br>
(only used to contact you for recruitment resons)<br>
CTPORFILE Link: $_POST[ctprofile]<br>
Profession 1-$_POST[pro1] Profession 2-$_POST[pro2]<br>
Atunements:<br>
Molten Core- $_POST[mc]<br>
Onyxia's Lair-$_POST[ony]<br>
Blackwing Lair-$_POST[bwl]<br>
Naxxramas-$_POST[nax]<br>
Vent/mod/add-on Requirements: $_POST[will]<br>
Unbuffed Resists:<br>
Arcane:$_POST[arcane]<br>
Fire:$_POST[fire]<br>
Nature:$_POST[nature]<br>
Frost:$_POST[frost]<br>
Shadow:$_POST[shadow]<br>
About you: $_POST[about]<br>
Why Ascensio: $_POST[whyus]<br>
Old Guild 1: $_POST[og1]<br>
Old Guild 2: $_POST[og2]<br>
Old Guild 3: $_POST[og3]<br>
Reason for leaving each: $_POST[ogreason]<br>
What wait for 5 sunders means to me:<br> $_POST[sunder]<br>
RAID Atten weekly: $_POST[week]<br>
Randomness: $_POST[randomness]<br>
Path Clearing: $_POST[pathdestroy]";
//start building the mail string
$msg = "The information for $_POST[char]
Voucher: $_POST[voucher]
Charaters Level: $_POST[lvl]
Class: $_POST[class]
Build: $_POST[build]
Contact E-Mail: $_POST[email]
(only use for recruitment reasons do not post in forums)
CTPROFILE Link: $_POST[ctprofile]
Profession 1-$_POST[pro1]
Profession 2-$_POST[pro2]
Attunements:
Molten Core-$_POST[mc]
Onyxia's Lair-$_POST[ony]
Blackwing Lair-$_POST[bwl]
Naxxramas-$_POST[nax]
Vent/mod/add-on Requirements: $_POST[will]
Unbuffed Resists: Arcane:$_POST[arcane]
Fire:$_POST[fire]
Nature:$_POST[nature]
Frost:$_POST[frost]
Shadow:$_POST[shadow]
About you: $_POST[about]
Why Ascensio: $_POST[whyus]
Old Guild 1: $_POST[og1]
Old Guild 2: $_POST[og2]
Old Guild 3: $_POST[og3]
Reason for leaving each: $_POST[ogreason]
What wait for 5 sunders means to me: $_POST[sunder]
RAID Atten weekly: $_POST[week]
Randomness: $_POST[randomness]
Path Clearing: $_POST[pathdestroy]";
//set up the mail
$recipient = "removed";
$subject = "Guild Entry for $_POST[char], $_POST[class]";
$mailheaders = "From: Ascensio App form";
$mailheaders = "Reply-To: cgimana@adelphia.net";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>

-Hoped I helped. Don't forget this site is Member supported.
 
PUt code in a code box - do this:

[ignore]
Code:
Here's my code - much easier to read
[/ignore]

... to get this :

Code:
Here's my code - much easier to read

Regards
 
You are missing a parenthesis at the end of your if statement.
Same one I left out by mistake in my example. Always keep parenthesis in even numbers.If you open one you have to close it somehwere.

So
Code:
if(($_POST['class']==warrior)||...($_POST['class']=="druid")[red])[/red]
[blue]{[/blue]
echo "Sorry...";
[blue]}[/blue]
else
[blue]{[/blue]
[green]rest of code goes here[/green]
[blue]}[/blue]

Curly braces remeber to enlcose your code inside if's and loops (whiles,for's etc..) in curly braces. "[blue]{[/blue]" and "[blue]}[/blue]"

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Got the if statements to work sweetness.....thx guys
overyde (Programmer)

Putting that line in doesn't do anything, do I have put in both variables?
And how do I get the / not to show up in the echo's of hte set text?
So to hove the ' show as ' in the class field"
Code:
$class = stripslashes($_POST[postdata]);
and I'd have to do this for each varable?

-Hoped I helped. Don't forget this site is Member supported.
 
You need to put stripslashes() around any variable with the slashes problem eg:
Code:
"Charater Requesting: ".stripslashes($_POST["char"])."<br>"
Also, you need to call the post data with quotes. so it's $_POST["char"] and not $_POST[char]. You best bet to avoid accidentally ending your echo string is to add it with .s like I did in the above example.
 
I'm giving up on the stripslashing...it's not that big of a deal.....

But now that I got my if statements going....
The statement for if class=Select doesn't work. If you don't select your class you get a return of nothing. But if you select a class, if still pulls up the if statement for the mailto. This form can be tested at so you can see what it is doing.

My code is:

Code:
<?php
if(($_POST['will']=="No"))
{
echo "We are sorry but we are not looking for a player not willing to use the add-ons or Ventrillo that everyone is required to use. If you selected the wrong answer please hit your BACK button and review your answer";
}
else
if(($_POST['voucher']=="Select"))
{
echo "You have not selected a voucher. Are you sure you do not have someone in the guild to ask to vouch for you? Please make sure they know you are using them as a voucher.";
}
else
if(($_POST['lvl']=="Select"))
{
echo "Please select a level";
}
else
if(($_POST['class']=="Selcet"))
{
echo "Please select your class.";
}
else
if(($_POST['pro1']=="Selcet")||($_POST['pro2']=="Selcet"))
{
echo "Please select both of your professions.";
}
else
if(($_POST['mc']=="Selcet")||($_POST['ony']=="Selcet")||($_POST['bwl']=="Selcet")||($_POST['nax']=="Selcet"))
{
echo "Please select weather or not you have each attunement.";
}
else
if(($_POST['will']=="Selcet"))
{
echo "Please let us know if you are willing to us the add-ons and Ventrilo which is a requirement of joining and remaining with Ascensio.";
}
else
if(($_POST['week']=="Selcet"))
{
echo "Please select how many times a week you will be RAIDing with us.";
}
else
if(($_POST['sunder']=="Selcet"))
{
echo "We really need to know why you need to wait for 5 sunders.";
}
else
if(($_POST['pathdestroy']=="Selcet"))
{
echo "Please select weather or not you are willing to destroy everything in our path!";
}
else
if(($_POST['class']=="Warrior")||($_POST['class']=="Hunter")||($_POST['class']=="Rogue")||($_POST['class']=="Priest")||($_POST['class']=="Warlock")||($_POST['class']=="Druid"))
{
echo "Thank you for filling out an Ascensio recruitment application. However, we only have room for Mages and Palidins. We will still look over your application and get back to you shortly.<br>
<br>
The information you inputted was:<br>
Voucher: $_POST[voucher]<br>
Characters Level: $_POST[lvl]<br>
Class: $_POST[class]<br>
Build: $_POST[build]<br>
Contact E-Mail: $_POST[email]<br>
(only used to contact you for recruitment reasons)<br>
CTPORFILE Link: $_POST[ctprofile]<br>
Profession 1-$_POST[pro1]<br>
Profession 2-$_POST[pro2]<br>
Attunements:<br>
Molten Core- $_POST[mc]<br>
Onyxia's Lair-$_POST[ony]<br>
Blackwing Lair-$_POST[bwl]<br>
Naxxramas-$_POST[nax]<br>
Vent/mod/add-on Requirements: $_POST[will]<br>
Unbuffed Resists:<br>
Arcane: $_POST[arcane]<br>
Fire :$_POST[fire]<br>
Nature: $_POST[nature]<br>
Frost: $_POST[frost]<br>
Shadow: $_POST[shadow]<br>
About you: $_POST[about]<br>
Why Ascensio: $_POST[whyus]<br>
Old Guild 1: $_POST[og1]<br>
Old Guild 2: $_POST[og2]<br>
Old Guild 3: $_POST[og3]<br>
Reason for leaving each: $_POST[ogreason]<br>
What wait for 5 sunders means to me:<br> $_POST[sunder]<br>
RAID Attend weekly: $_POST[week]<br>
Randomness: $_POST[randomness]<br>
Path Clearing: $_POST[pathdestroy]";
//start building the mail string
$msg = "This application is for a class we are currently not recruiting.
The information for $_POST[char]
Voucher: $_POST[voucher]
Characters Level: $_POST[lvl]
Class: $_POST[class]
Build: $_POST[build]
Contact E-Mail: $_POST[email]
(only use for contact for recruitment resons do not post in forums)
CTPROFILE Link: $_POST[ctprofile]
Profession 1-$_POST[pro1]
Profession 2-$_POST[pro2]
Attunements:
Molten Core-$_POST[mc]
Onyxia's Lair-$_POST[ony]
Blackwing Lair-$_POST[bwl]
Naxxramas-$_POST[nax]
Vent/mod/add-on Requirements: $_POST[will]
Unbuffed Resists:
Arcane: $_POST[arcane]
Fire: $_POST[fire]
Nature: $_POST[nature]
Frost: $_POST[frost]
Shadow: $_POST[shadow]
About you: $_POST[about]
Why Ascensio: $_POST[whyus]
Old Guild 1: $_POST[og1]
Old Guild 2: $_POST[og2]
Old Guild 3: $_POST[og3]
Reason for leaving each: $_POST[ogreason]
What wait for 5 sunders means to me: $_POST[sunder]
RAID Attend weekly: $_POST[week]
Randomness: $_POST[randomness]
Path Clearing: $_POST[pathdestroy]";
//set up the mail
$recipient = "cgimana@adelphia.net";
$subject = "From: Class not recruiting.";
$mailheaders = "From: Ascensio App form";
$mailheaders = "Reply-To: cgimana@adelphia.net";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
if(($_POST['class']=="Mage")||($_POST['class']=="Paladin"))
{
echo "Thank you, $_POST[char], for your request. It has been sent to 5 of 11 council members for review, you will be contacted either in game or by e-mail.</p>
<p>The information you inputted was:<br>
Character Requesting: $_POST[char]<br>
Voucher: $_POST[voucher]<br>
Characters Level: $_POST[lvl] 
Class: $_POST[class]<br>
Build: $_POST[build]<br>
Contact E-Mail: $_POST[email]<br>
(only used to contact you for recruitment reasons)<br>
CTPORFILE Link: $_POST[ctprofile]<br>
Profession 1-$_POST[pro1] Profession 2-$_POST[pro2]<br>
Attunements:<br>
Molten Core- $_POST[mc]<br>
Onyxia's Lair-$_POST[ony]<br>
Blackwing Lair-$_POST[bwl]<br>
Naxxramas-$_POST[nax]<br>
Vent/mod/add-on Requirements: $_POST[will]<br>
Unbuffed Resists:<br>
Arcane: $_POST[arcane]<br>
Fire: $_POST[fire]<br>
Nature: $_POST[nature]<br>
Frost: $_POST[frost]<br>
Shadow: $_POST[shadow]<br>
About you: $_POST[about]<br>
Why Ascensio: $_POST[whyus]<br>
Old Guild 1: $_POST[og1]<br>
Old Guild 2: $_POST[og2]<br>
Old Guild 3: $_POST[og3]<br>
Reason for leaving each: $_POST[ogreason]<br>
What wait for 5 sunders means to me:<br> $_POST[sunder]<br>
RAID Atten weekly: $_POST[week]<br>
Randomness: $_POST[randomness]<br>
Path Clearing: $_POST[pathdestroy]";
//start building the mail string
$msg = "The information for $_POST[char]
Voucher: $_POST[voucher]
Characters Level: $_POST[lvl]
Class: $_POST[class]
Build: $_POST[build]
Contact E-Mail: $_POST[email]
(only use for recruitment reasons do not post in forums)
CTPROFILE Link: $_POST[ctprofile]
Profession 1-$_POST[pro1]
Profession 2-$_POST[pro2]
Attunements: 
Molten Core-$_POST[mc]
Onyxia's Lair-$_POST[ony]
Blackwing Lair-$_POST[bwl]
Naxxramas-$_POST[nax]
Vent/mod/add-on Requirements: $_POST[will]
Unbuffed Resists: Arcane:$_POST[arcane]
Fire:$_POST[fire]
Nature:$_POST[nature]
Frost:$_POST[frost]
Shadow:$_POST[shadow]
About you: $_POST[about]
Why Ascensio: $_POST[whyus]
Old Guild 1: $_POST[og1]
Old Guild 2: $_POST[og2]
Old Guild 3: $_POST[og3]
Reason for leaving each: $_POST[ogreason]
What wait for 5 sunders means to me: $_POST[sunder]
RAID Atten weekly: $_POST[week]
Randomness: $_POST[randomness]
Path Clearing: $_POST[pathdestroy]";
//set up the mail
$recipient = "cgimana@adelphia.net";
$subject = "Guild Entry for $_POST[char], $_POST[class]";
$mailheaders = "From: Ascensio App form";
$mailheaders = "Reply-To: cgimana@adelphia.net";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
}
?>


-Hoped I helped. Don't forget this site is Member supported.
 
You say that
The statement for if class=Select doesn't work.
and your code says
Code:
if(($_POST['class']=="[COLOR=red]Selcet[/color]"))

Looks like a typo to me :)

Regards

 
Ahh yes...I figured that out. I made one that was typo'd and used that one to copy-paste for all the fields so most were spelled wrong. Someone said, "Welcome to the programming world."

-Hoped I helped. Don't forget this site is Member supported.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top