Jump to content

kelharis

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kelharis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everyone, I am creating a short little form that will email the submitted information to someone using MS Outlook mail. I have tested my code and it will email the correct email, email the correct subject, but I have an error somewhere in the "message" section. I have probably just made some idiotic mistake as usual, but I can't find it. here is the code, the message in the email just reads as the variable $message is written, i.e. "$name /n $email /n $school /n $diet" Where am I going wrong? <?php $name = $_REQUEST ['name'] ; $email = $_REQUEST['email'] ; $school = $_REQUEST['school'] ; $diet = $_REQUEST['diet'] ; $message = '$name /n $email /n $school /n $diet'; mail( "XXXXXXXXX", "Subject: Leadership Seminar Signup", $message, "From: $email" ); //if "email" is not filled out, display the form echo "<center><form method='post' action='pages/leadershipform.php'> Name: <input name='name' type='text' /><br /> Email: <input name='email' type='text' /><br /> School: <input name='school' type='text' /><br /> Special Dietary Needs: <input name='diet' type='text' /> <br /> <input type='submit' /> </form>"; ?>
  2. I am trying to write a currency calculator form and I am running into a problem. Everything seems to work correctly, except for the final calculation. The user will input an amount and then select via radio button one of four currencies, which will then be run through a calculation and returned as a dollar amount. The radio buttons are returning a value for me, but I need to be able to assign a variable based upon that value, and I think I might be on the wrong track. My current code tries to do this via a switch command, but I have also tried using a series of elseif statements. Here is the current switch code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> </head> <body> <?php $amount = $_POST["amount"]; $currency = $_POST["currency"]; $calcamt = $amount*$calccurr; if ($_POST["amount"] != NULL){ switch ($currency) { case "GBP": $calccurr = 0.6397; break; case "CAD": $calccurr = 1.18659; break; case "EUR": $calccurr = 0.786225; break; case "AUD": $calccurr = 1.4653; break; } echo "$amount $currency converts to $calcamt Dollars"; } echo <<<HEREDOC <form action='test.php' method='post'> <table width=400px height=650px cellspacing=0 cellpadding=3 border=0 align='center' > <tr> <td class='sub-title' colspan=2 style='height: 60px;' valign='center' align='center'> <b>Dollar Conversion Form</b> </td> </tr> <tr> <td colspan=2 style='height: 100px;'> </td> </tr> <tr> <td class='lable' valign='top'> Amount </td> <td class='txtbx' valign='top' align='left'> <input name='amount' type='textbox' maxlength='30' style="width: 200px;"> </td> </tr> <tr> <td valign='top' align='center'> <b>Select Currency Type</b> </td> <td><fieldset> <label>British Pounds<input type="radio" name="currency" value="GBP" /> </label> <br /> <label>Canadian Dollars<input type="radio" name="currency" value="CAD" /> </label> <br /> <label>Euros<input type="radio" name="currency" value="EUR" /> </label> <br /> <label>Australian Dollars<input type="radio" name="currency" value="AUD" /> </label> <br /> </td> </tr> <tr> <td colspan=2 style='padding-left: 25px;'> <input type="submit" name="submit" value="Calculate Value"> </td> </tr> <tr> <td colspan=2 style='height: 300px;'> </td> </tr> </table> </form> HEREDOC; ?> </body> </html> Here is the elseif attempt: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> </head> <body> <?php $amount = $_POST["amount"]; $currency = $_POST["currency"]; $calcamt= $amount*$calccurr; if ($_POST["amount"] != NULL){ if ($currency = "GBP"){ $calccurr = 0.6397; } elseif ($currency = "CAD"){ $calccurr = 1.18659; } elseif ($currency = "EUR"){ $calccurr = 0.786225; } elseif ($currency = "AUD"){ $calccurr = 1.46563; } echo "$amount $currency converts to $calcamt Dollars"; } echo <<<HEREDOC <form action='test.php' method='post'> <table width=400px height=650px cellspacing=0 cellpadding=3 border=0 align='center' > <tr> <td class='sub-title' colspan=2 style='height: 60px;' valign='center' align='center'> <b>Dollar Conversion Form</b> </td> </tr> <tr> <td colspan=2 style='height: 100px;'> </td> </tr> <tr> <td class='lable' valign='top'> Amount </td> <td class='txtbx' valign='top' align='left'> <input name='amount' type='textbox' maxlength='30' style="width: 200px;"> </td> </tr> <tr> <td valign='top' align='center'> <b>Select Currency Type</b> </td> <td><fieldset> <label>British Pounds<input type="radio" name="currency" value="GBP" /> </label> <br /> <label>Canadian Dollars<input type="radio" name="currency" value="CAD" /> </label> <br /> <label>Euros<input type="radio" name="currency" value="EUR" /> </label> <br /> <label>Australian Dollars<input type="radio" name="currency" value="AUD" /> </label> <br /> </td> </tr> <tr> <td colspan=2 style='padding-left: 25px;'> <input type="submit" name="submit" value="Calculate Value"> </td> </tr> <tr> <td colspan=2 style='height: 300px;'> </td> </tr> </table> </form> HEREDOC; ?> </body> </html> Both are returning the echo string correctly, but they return a value of 0 instead of the actual calculation. Where am I going wrong? Thanks for any help!
×
×
  • 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.