mike1313 Posted March 21, 2007 Share Posted March 21, 2007 With an form input box I need to check to see if the user typed after something say they typed "hello Bob Franklin" I need it to select Bob and Franklin in 2 seperate forms, how can I do this? Quote Link to comment Share on other sites More sharing options...
RyanSF07 Posted March 21, 2007 Share Posted March 21, 2007 Does this help? Send your form -- <form action = "bob_franklin_process.php" method = "post"> <table id = "First_and_Last_name_Table"> <tr> <td class = "left"><b>first name:</b> </td> <td class = "right"><input type = "text" name = "first_name" size = "30" maxlength = "30" /></td> </tr> <tr> <td class = "left"><b>last name:</b> </td> <td class = "right"><input type = "text" name = "last_name" size = "30" maxlength = "30" /></td> </tr> </table> </form> to a processor script like this: <?php include_once ("connect2database.php"); // database connection //query database if ($_POST[submit]) { // php validation if ($_POST[first_name] <> "") { $a = TRUE; } else { $a = FALSE; $content .= "<p>Please click your browser's BACK button and enter your first name.</p>\n"; } if ($_POST[last_name] <> "") { $b = TRUE; } else { $b = FALSE; $content .= "<p>Please click your browser's BACK button and enter your last name.</p>\n"; } } if($a && $b ) { //if required fields are true // do insert here $query = "INSERT INTO table VALUES ('0', '$_POST[first_name]', '$_POST[last_name]', } ?> Quote Link to comment Share on other sites More sharing options...
mike1313 Posted March 21, 2007 Author Share Posted March 21, 2007 That would work but I need to find out what they are typing in the same input box though. Quote Link to comment Share on other sites More sharing options...
mike1313 Posted March 21, 2007 Author Share Posted March 21, 2007 bump Quote Link to comment Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 Really it is impossible to do that without knowing something constant. IE: if they will ALWAYS do it like hello Bob Franklin, we can help. But if they can enter in Jack and coke = Bob Franklin, well thats a little tougher. Or even Hello my name is Bob and my last name is Franklin. How do you Do? Can you provide anymore information on the matter? Quote Link to comment Share on other sites More sharing options...
mike1313 Posted March 21, 2007 Author Share Posted March 21, 2007 using <input type-text name=somevar> Alright say they type /word Hello Guy I just need something where it can select "Hello" and "Guy" into 2 seperate strings. So I can run 2 different queries. Quote Link to comment Share on other sites More sharing options...
UTAlan Posted March 21, 2007 Share Posted March 21, 2007 If you always want to select the second and third words: <?php $words = explode(" ", $_POST['inputBox']); $two = $words[2]; $three = $words[3]; ?> Quote Link to comment Share on other sites More sharing options...
mike1313 Posted March 21, 2007 Author Share Posted March 21, 2007 What if I want to select the 2nd word than everything 3rd word and on? Quote Link to comment Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 <?php $words = explode(" ", $_POST['inputBox']); foreach ($words as $word) { print $word . "<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.