code is working properly. When it times to press the submit button it didn't give any answer or error. I'd also tried to change the form< action="..." > and place the result in another file but it didn't show anything.
<form action= "" methods="post">
<!-- image section start from here -->
<div class="desc"> E-LN3465 <br/> PRICE: 5000 Pkr <br/><input type="text" name="E-LN3465" value="1" /> </div>
<div class="desc">E-LN7645 <br/> PRICE: 4000 Pkr <br/><input type="text" name="E-LN7645" value="1" /></div>
<div class="desc">E-LN7644 <br/> PRICE: 5000 Pkr<br/><input type="text" name="E-LN7644" value="1" /></div>
<div class="desc">E-LN3456 <br/> PRICE: 8000 Pkr <br/><input type="text" name="E-LN3456" value="1" /> </div>
<div class="desc">E-LN7863 <br/> PRICE: 4900 Pkr <br/><input type="text" name="E-LN7863" value="1" /></div>
<div class="desc">E-LN6709 <br/> PRICE: 5000 Pkr<br/><input type="text" name="E-LN6709" value="1" /> </div>
<p><input type="submit" name=" submit" value="Add to cart" /></p>
<?php
if(isset($_POST['submit']))
{ echo $_POST['E-LN6709']; }
?>
</form>
NB: Making this as a community wiki. I feel there should be no personal gain from this answer.
As outlined in comments:
Use method="post"
(without the s
in method
). – D4V1D
also, <input type="text" name="E-LN6709" value="1" /
needs a >
on the end – Adam
But this one I caught after:
name=" submit"
Your conditional statement will fail because of the space in there.
name="submit"
Add error reporting to the top of your file(s) which will help find errors.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
Sidenote: Displaying errors should only be done in staging, and never production.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.