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? Link to comment https://forums.phpfreaks.com/topic/43619-string-help/ 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]', } ?> Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-211816 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. Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-211818 Share on other sites More sharing options...
mike1313 Posted March 21, 2007 Author Share Posted March 21, 2007 bump Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-211982 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? Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-211990 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. Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-212173 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]; ?> Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-212178 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? Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-212328 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 />"; } ?> Link to comment https://forums.phpfreaks.com/topic/43619-string-help/#findComment-212331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.