Lawlssbatmbl Posted August 26, 2013 Share Posted August 26, 2013 Ive been working on a simple web form I wanted to replace the basic submit button with icon images , but for some reason my posts dont seem to work now. Can you offer some solutions. echo "<table align=\"center\" width=\"500\" border=\"0\" background=\"images/FormBG.png\">"; echo "<tr><td colspan=\"5\" height=\"50\"><font size=\"5\">Excision Type</font><td></tr>"; echo "<tr><th>ID</th><th>Type</th><th>Name</th></tr>"; while ($stmt->fetch()) { echo "<form method=\"post\" action=\"excision.php\"> "; echo "<tr><td><input name=\"excision_id\" type=\"hidden\" value=" . $excision_id . ">" . $excision_id . "</td>" ; echo "<td><input name=\"excision_type\" type=\"text\" value=" . $excision_type . "></td>"; echo "<td><input name=\"excision_name\" type=\"text\" value=" . $excision_name . "></td>"; echo "<td><input name=\"edit\" src=\"/IC/images/Clipboard 3.png\" type=\"image\" style=\"height:24px; width:24px \" value=\"Edit\"></td>"; echo "<td><input name=\"delete\" src=\"/IC/images/Close - Cancel 1.png\" type=\"image\" style=\"height:24px; width:24px \" value=\"Delete\"></td></tr>"; echo "</form>"; } echo "<form method=\"post\" action=\"excision.php\"> "; echo "<tr><td> </td>" ; echo " <td><input name=\"a_excision_type\" type=\"text\"></td>"; echo " <td><input name=\"a_excision_name\" type=\"text\"></td>"; echo " <td><input name=\"add\" src=\"/IC/images/Add Green.png\" type=\"image\" style=\"height:24px; width:24px \" value=\"Add\"></td>"; echo " <td></td></tr>"; echo "</form>" ; echo "</table>" ; Heres the example of the post code higher up in the same php script. if (ISSET($_POST['add'])) { $exc_type = mysqli_real_escape_string($db,$_POST['a_excision_type']); $exc_name = mysqli_real_escape_string($db,$_POST['a_excision_name']); if (strlen($exc_type) > 20) fail('Excision Type too long (MAX : 20 characters)'); if (strlen($exc_name) > 45) fail('Excision Name too long (MAX : 45 characters)'); ($astmt = $db->prepare('insert into excision_type (excision_type, excision_name) values (?,?)')) || fail('MySQL prepare', $db->error); $astmt->bind_param('ss', $exc_type, $exc_name) || fail('MySQL bind_param', $db->error); if (!$astmt->execute()) { /* Figure out why this failed - maybe the username is already taken? * It could be more reliable/portable to issue a SELECT query here. We would * definitely need to do that (or at least include code to do it) if we were * supporting multiple kinds of database backends, not just MySQL. However, * the prepared statements interface we're using is MySQL-specific anyway. */ if ($db->errno === 1062 /* ER_DUP_ENTRY */) fail('This Excision Type is already taken.'); else fail('MySQL execute', $db->error); } } I know the code works when I use the type="submit" so its not a syntax issue , I suspect that changing type from "submit" to "image" has some suttle differences. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/ Share on other sites More sharing options...
fastsol Posted August 26, 2013 Share Posted August 26, 2013 Post your processing php for the form. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446746 Share on other sites More sharing options...
AbraCadaver Posted August 26, 2013 Share Posted August 26, 2013 On excision.php you need to do a print_r($_POST) to see what the buttons are named. Instead of "add" you'll have two like "add_x" and "add_y" and the values will be the coordinates of the image that were clicked. Most likely in excision.php you're checking for $_POST['add'] or something similar. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446750 Share on other sites More sharing options...
Lawlssbatmbl Posted August 26, 2013 Author Share Posted August 26, 2013 You are right i'm just checking using ISSET($_POST('add')) can you give me an example of how I would change this. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446752 Share on other sites More sharing options...
AbraCadaver Posted August 26, 2013 Share Posted August 26, 2013 Well, try "add_x", but maybe do a print_r($_POST) on excision.php and check it to make sure that I'm correct on the naming. You'll need to change the isset for the edit and delete as well. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446753 Share on other sites More sharing options...
AbraCadaver Posted August 26, 2013 Share Posted August 26, 2013 On the add form you could set a hidden input named "add" since that's the only possibility for that form, but that won't help you on the edit/delete form because that hidden input won't let you know which button was clicked. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446754 Share on other sites More sharing options...
Lawlssbatmbl Posted August 26, 2013 Author Share Posted August 26, 2013 Checked the $_POST('add_x') value being set fixed the issue . Thanks for the help. Consider this solved. Link to comment https://forums.phpfreaks.com/topic/281554-change-from-submit-to-image-type-stops-post-working/#findComment-1446771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.