Use image as submit button, How to use a graphic as a submit button |
Use image as submit button, How to use a graphic as a submit button |
The-Yikes |
May 27 2020, 03:49 PM
Post
#1
|
Group: Members Posts: 6 Joined: 27-May 20 Member No.: 27,365 |
Hi! I'm hoping someone here can help me out.
I'm trying to use an image as a submit button which in turn loads a php script. Here's what I have HTML File: CODE <html> <head> <title>No title</title> <meta name="generator"> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red"> <form name="form1" method="post" action="post.php"> <p> </p> <table border="1" width="407"> <tr> <td width="200"> <p><input type="text" name="name"></p> </td> <td width="191"> <p><input type="text" name="pwd"></p> <p><input type="image" name"submit_btn" src="button1.jpg" alt"Submit"></p> <p></p> </td> </tr> <tr> <td width="397" colspan="2"><input type="submit" name="submit_btn"></td> </tr> </table> </form> <p> </p> </body> </html> And here's what i have for the php: CODE <?php if(isset($_POST['submit_btn'])) { $username = $_POST['name']; $password = $_POST['pwd']; $text = $username . "," . $password . "\n"; $fp = fopen('data.txt', 'a+'); if(fwrite($fp, $text)) { echo 'saved'; } fclose ($fp); } ?> <html> It works fine with a standard Submit button. I would really appreciate any little bit of help you can offer! |
The-Yikes |
May 28 2020, 06:33 AM
Post
#2
|
Group: Members Posts: 6 Joined: 27-May 20 Member No.: 27,365 |
Thanks Pandy! I changed the line to read the following
CODE <p><input type="image" name="submit_btn" src="button1.jpg"></p> But it'still not working. It loads the next page but it's not writing to the text file. P.s thanks for the quick reply! |
pandy |
May 28 2020, 07:15 AM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Hmm. Could it be that different names have to be used? The typical situation is you WANT different names to be able to know which button was pushed. I don't know, just a thought. Do you know, Christian?
BTW, the equal sign for alt is missing too, in the same tag. I didn't notice. |
Christian J |
May 28 2020, 07:24 AM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Hmm. Could it be that different names have to be used? The typical situation is you WANT different names to be able to know which button was pushed. I don't know, just a thought. Do you know, Christian? Other form elements (like radio buttons) can have identical names (and you tell them apart by their VALUE attributes). Haven't found anything in the specs yet about submit buttons, but some online examples do use identical names, e.g. here: https://stackoverflow.com/a/547848 |
Lo-Fi Version | Time is now: 25th April 2024 - 08:38 PM |