Goose87 Posted June 23, 2008 Share Posted June 23, 2008 Hey guys, This is quite an embarassing question, as I'm probably being VERY stupid! but I'm really ill at the moment so I can't think properly. When I normally have a form I'll have the normal: <form method="post"...... > <input type="submit" value="Submit" name="button1"> </form> and the php would be: if(isset($_POST['submit'])){ ** do something ** } I've got to use the <input type="image" ... > for the new layout i've got and I've hit a snag.... if(isset($_POST['submit'])){ doesn't work any more because it's not a submit button. Can anyone help me out? Cheers. Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/ Share on other sites More sharing options...
gijew Posted June 23, 2008 Share Posted June 23, 2008 Are you trying to see if the "image" field has a value or not? If that's the case you just check for it by field name or even see if any $_FILES[] are present. But to answer you, the button for the image field isn't a submit button although you could emulate it with javascript. Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572634 Share on other sites More sharing options...
Goose87 Posted June 23, 2008 Author Share Posted June 23, 2008 I'm trying to submit data that is in a form. The form i'm submitting is a message system within a game. Has two fields in it, and i just want to initiate the PHP code when the user presses the image button. I COULD do it via the $_GET function, but if you use $_GET, then I have problems sending large bits of data and stuff, so i'd prefer to send it via $_POST. Any ideas? Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572637 Share on other sites More sharing options...
DarkWater Posted June 23, 2008 Share Posted June 23, 2008 The image input type sends out two POST (or GET) variables. $_POST['name_x']; $_POST['name_y']; Where name is your input field name. It refers to the exact location that the button was clicked. Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572641 Share on other sites More sharing options...
Goose87 Posted June 23, 2008 Author Share Posted June 23, 2008 Yeah I read that somewhere, but what do i need to put in my code to replace the old: if(isset($_POST['submit'])){ so that I let the script know that the button has been clicked? I'm just baffled, there doesn't seem to be anything. Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572646 Share on other sites More sharing options...
DarkWater Posted June 23, 2008 Share Posted June 23, 2008 Uhh.... if (isset($_POST['submit_x'])) { } if ($_SERVER['REQUEST_METHOD'] == "POST") { } Either will work. Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572651 Share on other sites More sharing options...
Goose87 Posted June 23, 2008 Author Share Posted June 23, 2008 Legend. Thanks a lot man. I've got a fever at the moment so I'm really struggling to use my head thanks! Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572655 Share on other sites More sharing options...
DarkWater Posted June 23, 2008 Share Posted June 23, 2008 No problem, any time. =) Link to comment https://forums.phpfreaks.com/topic/111566-solved-processing-form-data-simple-problem/#findComment-572657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.