Simple HTML form is not working properly...
attached is a simple HTML form.
When i print the super global $_POST[] i don't get any information from the text fields.
Im really frustrated... I can't find any problem with the code...


HTML

<form method="POST" action="functions/process_payment.php" >
                	
                    <table id="creditCards">
                    	<tr>
                        	<td><input type="radio" name="creditCard" class="CreditCard" checked value="Visa"/><img src="images/checkout/visa.png" />&nbsp;Visa</td>
                            <td><input type="radio" name="creditCard" class="CreditCard" value="Mastercard"/><img src="images/checkout/master.png" />&nbsp;Master Card</td>
                            <td><input type="radio" name="creditCard" class="CreditCard" value="Amex"/><img src="images/checkout/amex.png" />&nbsp;Amex</td>
                        </tr>
                    </table>
                    
                    <table id="paymentInfo">
                    	<tr>
                        	<th>Card Holder Name:</th>
                            <td><input type="text" name"cardHolderName"  id="CardHolderName" /></td>
                        </tr>
                        <tr>
                        	<th>Card Number:</th>
                            <td><input type="text" name"cardNumber" id="CardNumber" /></td>
                        </tr>
                        <tr>
                        	<th>Card Expiry:</th>
                            <td>
                            <select name="ddlExpiryMonth" id="ddlExpiryMonth">
                            <option value="01">01</option>
                            <option value="02">02</option>
                            <option value="03">03</option>
                            <option value="04">04</option>
                            <option value="05">05</option>
                            <option value="06">06</option>
                            <option value="07">07</option>
                            <option value="08">08</option>
                            <option value="09">09</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                        	</select>
                   			<select name="ddlExpiryYear" id="ddlExpiryYear">
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                        	</select>
                            </td>
                        </tr>
                    </table>
                    
                    <table id="buttonsTable">
                    	<tr>
                        	<td> <input type="image" name="processPayment" src="images/checkout/processPayment.png" width="119" height="39"></td>
                            <td><a href="functions/cancel_order.php"><img src="images/checkout/cancelOrder.png" /></a></td>
                        </tr>
                    </table>
                </form>

PHP File

<?php
	print_r($_POST);
?>

Output

Array ( [creditCard] => Visa [ddlExpiryMonth] => 01 [ddlExpiryYear] => 10 [processPayment_x] => 72 [processPayment_y] => 30 )

Recommended Answers

All 13 Replies

<form method="POST" action="functions/process_payment.php" >

use like this. why you are using form methode post in capitals.

method="post"

It doesn't really matter since it's case-insensitive....

It's really frustrating
I just don't see the problem! im starting to think that there is a problem on my local server settings....

lol u cant print the $_POST thats not right.u have to echo

$_POST[name of the text field here];
echo $_POST[creditCard]; make sure to use mysql_real_escape_string() if u are entering it in the databse?

$_POST is an associative array.
print_r() Prints human-readable information about a variable and it is the best
function to use when you want to print arrays...
since $_POST is an array, the best way to echo it is using print_r()...

I tried echo before printing the whole array and it's not working!

yours <input type="text" name"CardHolderName" mine <input type='text' name='CardHolderName' ??

ristar, if ur not going to even look at my post right, then i just wont help you. print_r is rediculous to use. u just need to echo each variable seperately!

Member Avatar for rajarajan2017
echo $_POST['cardHolderName']

print_r will print array values.

Member Avatar for Zagga

$_POST is an associative array.
print_r() Prints human-readable information about a variable and it is the best
function to use when you want to print arrays...
since $_POST is an array, the best way to echo it is using print_r()...

You tried this and it didn't work, so maybe it isn't the best way.

Try echoing each value seperately, as has been suggested.

echo is echo and print is print u can echo with print, or there wouldnt be an echo

still the op hasnt noticed, THERE IS NO EQUAL SIGN IN THE NAME OF THE INPUTS THAT ARENT BEING POSTED
THIS IS A HTML SCREWUP NOT A PHP SCREWUP

yours WRONG <input type="text" name"CardHolderName" correct <input type='text' name='CardHolderName' ??

i agree with almostbob, this one really has an html screwup. i mean this is common sense change it and see if u have an airor now op! let me know if it solves all yo probs. kthx

commented: Thank you +4

What IDE do you use?
Netbeans will do a lot of help for you plus Ctrl+Space will save you alot of typo pains :)

ditto evstevemd

any editor with code highlighting would throw an exception at the code errors, that is, change display colors where the code is not correct., makes simple omissions easy to spot

Notepad++
notepad2
just about any decent IDE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.