Jump to content

Whats wrong with this code...


Tayuke

Recommended Posts

Right. I am currently making a form using PHP, and that will send me the info from the forms once a person ahs submitting the info...however, I'm new to PHP, and error keep coming up...so, if you guys could take a look, and tell me, what on earth I have done wrong. I got thsi code off a site, and then modified it to my own requirements.Here's the code:

<?phpif (($Name == "") || ($Chara == "") || ($Money == "") || ($Currency == "")){ echo "<form name=form method=post action=mail.php>"; echo "<p class=bodymd>All fields of this form are required, I really don't think that's too much to ask...</p>";}if ($Name == ""){ echo "<p class=bodymd>'Universal Online' In-game Account Username:<br><input name=Name></p>";}else{ echo "<input type=hidden name=Name value=$Name>";}if ($Chara == ""){ echo "<p class=bodymd>Universal Online In-game Account Character<br><select name="Chara"><option value="chara1" selected>Character 1</option><option value="chara2">Character 2</option><option value="chara3">Character 3</option></select></p>";}else{ echo "<input type=hidden name=Chara value=$Chara>";}if ($Money == ""){ echo "<p class=bodymd>Amount Donating:<br><input name="Money"></p>";}else{ echo "<input type=hidden name=Money value=$Money>";}if ($Currency == ""){ echo "<p class=bodymd>Amount Donating:<br><select name="Currency"><option value="usd" selected>US Dollar</option><option value="aud">Australian Dollar</option><option value="cad">Canadian Dollar</option><option value="euro">Euro</option><option value="ukp">UK Pound</option></select></p>";}else{ echo "<input type=hidden name=Currency value=$Currency>";}if (($Name == "") || ($Chara == "") || ($Money == "") || ($Currency == "")){ echo "<input type=submit name=Submit value=Submit>"; echo "<input type=reset name=Reset value=Clear Form>"; echo "</form>";}else{ $message = "Name: $Name\nChara: $Chara\nMoney: $Money\nCurrency: $Currency\n"; mail ("tayuke@gwd1.net", "Donation for Coins - UO", $message); echo "<p class=bodymd>Thanks for submitting. Please, continue with the donation process, by clicking on the button below.</p>";}?>
This is where the error is...the last one anyway:
}if ($Chara == ""){ echo "<p class=bodymd>Universal Online In-game Account Character<br><select name="Chara"><option value="chara1" selected>Character 1</option><option value="chara2">Character 2</option><option value="chara3">Character 3</option></select></p>";}
Any Help would be great.Thanks in advanceTayuke
Link to comment
Share on other sites

You have to escape the quotation marks in the string you're going to print, like this:

}if ($Chara == ""){echo "<p class=bodymd>Universal Online In-game Account Character<br><select name=\"Chara\"><option value=\"chara1\" selected>Character 1</option><option value=\"chara2\">Character 2</option><option value=\"chara3\">Character 3</option></select></p>";}

Note the \ in front of the ".

Link to comment
Share on other sites

I guess you can use single quotes on the outside and use double quotes without having to use slashes... like below..............}if ($Chara == ""){echo '<p class=bodymd>Universal Online In-game Account Character<br><select name="Chara"><option value="chara1" selected>Character 1</option><option value="chara2">Character 2</option><option value="chara3">Character 3</option></select></p>';}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...