Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 09-21-2007, 10:55 PM   #1
Bmo
Solid State Member
 
Join Date: Jan 2007
Posts: 16
Default PHP form processing

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:
__________________

Bmo is offline   Reply With Quote
Old 09-25-2007, 08:42 PM   #2
Baseband Member
 
Join Date: Aug 2007
Posts: 96
Default Re: PHP form processing

My friend, you are not concatenating your "echo" statement.
PHP Code:
$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 Code:
$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..
__________________

__________________
Premium Web Hosting Provider ║ MambugHost.com
Need to upload files? ║ MambugLoad.com
Fast, Effective, Web Design ║ Mambug.com
Mambug is offline   Reply With Quote
Old 09-26-2007, 12:33 PM   #3
Bmo
Solid State Member
 
Join Date: Jan 2007
Posts: 16
Default Re: PHP form processing

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?
Bmo is offline   Reply With Quote
Old 09-26-2007, 03:11 PM   #4
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: PHP form processing

Well i guess you could make a script that says:

PHP Code:
<?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!
j03 is offline   Reply With Quote
Old 09-29-2007, 11:59 AM   #5
Bmo
Solid State Member
 
Join Date: Jan 2007
Posts: 16
Default Re: PHP form processing

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 Code:
<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
Bmo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 01:04 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0