PHP form processing

Bmo

Solid State Member
Messages
16
I'm using a php form I created. I am getting the email from the forum perfectly. My problem is that in the message, my inputted variables don't show...

Here is my code for contract.php

<form method="post" enctype="text/plain" action="backbone.php">
<fieldset style="display: inline;">
<?php
$ipi = getenv("REMOTE_ADDR");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />


<legend>Your Name</legend>

<input type="text" name="char" size="16">
</fieldset>

<fieldset style="display: inline;">
<legend>Target Name</legend>
<input type="text" name="target" size="16">
</fieldset>
<br>
<br>


<select name="gold">
<option value="1000">1,000</option>
<option value="2000">2,000</option>
<option value="3000">3,000</option>
<option value="4000">4,000</option>
<option value="5000">5,000</option>
<option value="6000">6,000</option>
<option value="7000">7,000</option>
<option value="8000">8,000</option>
<option value="9000">9,000</option>
<option value="10000">10,000</option>
<option value="10000plus">10,000+</option>
</select>
<br>
<br>


<p>
<b>Leave a message for the victim.</b>
<br>
<textarea cols="30" rows="3" name="deathmessage"></textarea><br>

<br>

Anonymous?
<select name="anonymousHit">
<option value="no">no</option>
<option value="yes">yes</option>
</select>
</p>
<p><br>
<input type="submit" value="Send">
<input type="reset" value="Start over">
</p>

</form>


And here is my code for backbone.php


<?php

$char = $_POST["char"];
$target = $_POST["target"];
$gold = $_POST["gold"];
$deathmessage = $_POST["deathmessage"];
$anonymousHit = $_POST["anonymousHit"];
$ip = $_POST["ip"];

$subject = "Contract received";

$message = "Contract received\n\n
Character: $char \n
Target: $target \n
Gold: $gold \n
Death message: $deathmessage \n
Anonymous: $anonymousHit \n
IP Address: $ip \n
";

mail("contracts@durmanhoth.com", $subject, $message);

?>


Here is the body of a message I receive from any input in the form...

Contract received


Character:

Target:

Gold:

Death message:

Anonymous:

IP Address:
 
My friend, you are not concatenating your "echo" statement.
PHP:
$message = "Contract received\n\n
Character: $char \n
Target: $target \n
Gold: $gold \n
Death message: $deathmessage \n
Anonymous: $anonymousHit \n
IP Address: $ip \n
";

Should be something like...

PHP:
$message = "Contract received\n\n
Character:". $char." \n
Target:". $target." \n
Gold:". $gold." \n
Death message:". $deathmessage." \n
Anonymous:". $anonymousHit ."\n
IP Address:" .$ip." \n
";

I think thats right... I did it in 2 seconds..
 
Hmm, I did it and it still didn't work...as you can tell, this is my first php script :p

I ran a print_r($_POST) and I just got Array()

I think the problem is in the actual gathering of the information...I'm guessing it's a syntax thing...I've been comparing it to other feedback type scripts and the syntax seems correct. Is there a way for me to run some sort of check to see what variables are gathered in the first php document?
 
Well i guess you could make a script that says:

PHP:
<?php
$char = $_POST["char"];
$target = $_POST["target"];
$gold = $_POST["gold"];
$deathmessage = $_POST["deathmessage"];
$anonymousHit = $_POST["anonymousHit"];
$ip = $_POST["ip"];

echo "char: $char,target: $target, gold: $gold, death: $deathmessage, anon: $anonymousHit, ip: $ip";
?>

or somthing? that should give you the contents of the variables. Bin i while since i've done any php whatsoever!
 
ok, I figured out that the form itself isn't gathering information...can anyone tell me what's wrong with this? It looks perfect to me!

PHP:
<form method="post" enctype="text/plain" action="backbone.php">


<fieldset style="display: inline;">
<legend>Your Name</legend>
<input type="text" name="char" size="16">
</fieldset>


<fieldset style="display: inline;">
<legend>Target Name</legend>
<input type="text" name="target" size="16">
</fieldset>
<br>
<br>

<select name="gold">
<option value="1000">1,000</option>
<option value="2000">2,000</option>
<option value="3000">3,000</option>
<option value="4000">4,000</option>
<option value="5000">5,000</option>
<option value="6000">6,000</option>
<option value="7000">7,000</option>
<option value="8000">8,000</option>
<option value="9000">9,000</option>
<option value="10000">10,000</option>
<option value="10000plus">10,000+</option>
</select>
<br>
<br>


<p>
<b>Leave a message for the victim.</b>
<br>
<textarea cols="30" rows="3" name="deathmessage"></textarea><br>

<br>

Anonymous?
<select name="anonymousHit">
<option value="no">no</option>
<option value="yes">yes</option>
</select>
</p>
<p><br>
<input type="submit" value="Send">
<input type="reset" value="Start over">
</p>

</form>
 
Back
Top Bottom