Pass variable to php from html form


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pass variable to php from html form
# 1  
Old 03-04-2010
Pass variable to php from html form

I am sure this is easy but I can't figure it out...

Here is the form.
PHP Code:
<?php
$searchString 
$_POST["search"];
if (!isset(
$_POST['submit']))
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="search.php">
<input type="text" size="20" maxlength="20" name="search">
<br />
<input type="submit" value="submit" name="submit">
</form>
</body>
</html>
Here is the script I am trying make work.
PHP Code:
$searcher = new
FileSystemStringSearch('/logs/','$searchString');
$searcher->run();
         
if(
$searcher->getResultCount() > 0) {
    echo(
'<p>Searched "'.$searcher->getSearchPath().'" for string
<strong>"'
.$searcher->getSearchString().'":</strong></p>');
    echo(
'<p>Search term found <strong>'.$searcher->getResultCount().'
times.</strong></p>'
);
    echo(
'<ul>');
        foreach(
$searcher->getResults() as $result) {
            echo(
'<li><em>'.$result['filePath'].', line
'
.$result['lineNumber'].'</em>:<br />
     
'
.$searcher->highlightSearchTerm($result['lineContents']).'</li>');
        }
    echo(
'</ul>');
} else {
    echo(
'<p>Searched "'.$searcher->getSearchPath().'" for string
<strong>"'
.$searcher->getSearchString().'":</strong></p>');
    echo(
'<p>No results returned</p>');
}
?> 
This is the result...
Searched "/logs/" for string "$searchString":
No results returned

Thanks in advance for the help.
# 2  
Old 03-04-2010
Things in single quotes are interpreted as literal strings, so you're literally hunting for '$searchString' instead of the value you wanted. You don't need to quote a single variable parameter for anything anyway. Try just $searchString instead of '$searchString'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Html form to submit data to bash script

hi all, im going to design a web html form so users can input what username and password they want to make the ftp account, once they enter in a username and password they click on the submit button and it submits it to a bash script and then the bash script will run and finish of making the... (3 Replies)
Discussion started by: robertkwild
3 Replies

2. Shell Programming and Scripting

feasibility of opening a website link from unix and get a response in the form of xml or html

i just wanted to know whether is it possible to open a website link and get a response in the form of xml or html format... the website is of local network... for example something like this wget http://blahblah.samplesite.com/blachblahcblach/User/jsp/ShowPerson.jsp?empid=123456 ... (2 Replies)
Discussion started by: vivek d r
2 Replies

3. Shell Programming and Scripting

pass argument to html upload form

I am using an html form and a php upload script to upload files. HTML form <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <td> <table... (1 Reply)
Discussion started by: anil510
1 Replies

4. Shell Programming and Scripting

MySQL bulk retrieval of database through html form

Have to delete this long post. Seems nobody would spent time on it. (0 Replies)
Discussion started by: yifangt
0 Replies

5. Shell Programming and Scripting

Pass values from web form to shell script

Hi, is it possible to pass more values from web form like textbox to shell script and if yes,how to do that.:confused::confused::confused: (2 Replies)
Discussion started by: tdev457
2 Replies

6. Solaris

man pages in html form

Hi I would like to convert standard online man pages from my solaris10 system into html form to publish it on my webpage. How this can be done in Sol10 ? thx for help. (2 Replies)
Discussion started by: presul
2 Replies

7. Shell Programming and Scripting

on HTML form, Call Expect in Perl problem

Hi I have a successfullly run perl script (by issuing command "perl sub.pl" under shell mode) and this sub.pl will call sub.exp successfully. The sub.exp expect script is basically to login to a server and run some commands and put the output into a sub.txt file, it takes about 5 seconds to... (0 Replies)
Discussion started by: cxbest
0 Replies

8. Shell Programming and Scripting

Converting %## back to special characters from an HTML form

I have an HTML form that sends email to a large list of users one at a time by matching an email address in peoplesoft to their username. It works great, except that special characters are converted to %## format. Is there a library of these I can use to sed them back (yes this is a crappy UNIX... (1 Reply)
Discussion started by: 98_1LE
1 Replies

9. Shell Programming and Scripting

HTML form to cgi help

I wrote a script to automate user account verification against peoplesoft. Now I want to make it available to my peers via the web. It is running on Solaris. I have the form written, but am not sure how to make it work. I think the form should call a perl cgi when submitted. The cgi should call... (7 Replies)
Discussion started by: 98_1LE
7 Replies

10. Shell Programming and Scripting

Passing FORM(HTML) variable to ksh

I am currently able to use the $QUERY_STRING variable and simply cut out what I need to be assigned as variables within the shell script. However, I've been able to use the "name" value assigned within the FORM(HTML) as a variable when I use perl. Why is it that ksh doesn't read the "name" in as... (1 Reply)
Discussion started by: douknownam
1 Replies
Login or Register to Ask a Question