miniop Posted November 9, 2010 Share Posted November 9, 2010 Hello all, Can someone help me ? I have a html/php with a contact form and anyone can write his name and press submit. Then his name is saved into a text. 1) Is it possible if someone write the url site like this www.mydomain.com/index.html?test={!variable} and complete the form name then in the plain text to be saved like this : {!varuable} , name. 2) And if someone try again to connect at the www.mydomain.com/index.html?test={!variable} and the variable is already in the text file then to redirect them to another page ? Thank you very much. Quote Link to comment Share on other sites More sharing options...
ttocskcaj Posted November 10, 2010 Share Posted November 10, 2010 Do you know how to use mysql? It would probably be easier in the long run than using a txt file. And yes it's possible Quote Link to comment Share on other sites More sharing options...
miniop Posted November 10, 2010 Author Share Posted November 10, 2010 >>Do you know how to use mysql? Yes and no but this is just for testing and i might change later to sql. ofcourse with sql will be easier. I succeed take a ?test=<variable> with php. Now anyone can help me how to pass this variable to another php ? Example : www.domain.com/1.php?name=123 on 1.php i have this code : <?php $num = $_GET['name']; ?> how i can pass the $num to another php like 2.php ? (2.php has the code so it can save the form to a text file ?) Thank you. Quote Link to comment Share on other sites More sharing options...
miniop Posted November 10, 2010 Author Share Posted November 10, 2010 >>Now anyone can help me how to pass this variable to another php ? Found that also. --- Now how i can serach a text file for a specific word and echo the result ? And also when the word is already 3 times in the text file then echo something else ? Like : i.txt contact the word "rock" php serach the i.txt for the specific word "rock" then echo your results is 1 time We add 2 time the word "rock" in the i.txt php seatch the i.txt for the specific word "rock" and it finds that there 3 time the word then echo END Thank you. Quote Link to comment Share on other sites More sharing options...
ttocskcaj Posted November 28, 2010 Share Posted November 28, 2010 That's why I said use sql lol. I think that's possible. but not as easy Quote Link to comment Share on other sites More sharing options...
The Letter E Posted December 5, 2010 Share Posted December 5, 2010 <?php //open file $file_handle = fopen("myfile.txt", "rb"); //explode file to array, split by space while (!feof($file_handle) ) { $words = explode(" ", $file_handle); } //set variables //catchWord $catchWord = 'myWord'; //catchLimit $catchLimit = 3; //loop over array and check against catchWord foreach($words as $word){ $i = 0; while($word == $catchWord){ if($i <= $catchLimit){ $i++; if($i > 1){$time = 'times';}else{$time = 'time';} echo 'The word '.$catchWord.' occurred '.$i.' '.$time.'.<br>'; } else{ break; } } } ?> That's a basic example of one way you can achieve the desired result. It would need a slight modification to work exactly the way you want, but this is the theory. I only tested it with a sample string. If there's an error during the file read portion I didn't really check that part, I'm sure you'll get it. Good luck. : ) 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.