LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   html to php? help me please!!!!! (http://www.linuxquestions.org/questions/programming-9/html-to-php-help-me-please-280943/)

trscookie 01-22-2005 03:07 PM

html to php? help me please!!!!!
 
hi im trying to write a html file that passes the information from a text field called query to a php page, that will store the information in a text file.
i have tried for hrs, using some code that one of my lectures gave me, but it doesnt seem to work? can any one help please?

tamoneya 01-22-2005 03:18 PM

post the code using the code button so that we can take a look at it. In general it is always much easier to solve a prblem once you know more about it.

trscookie 01-23-2005 06:38 AM

this is the html code:

<html>
<head>
<title>Student Search Engine</title>
</head>
<body>
<table width="800" border="0">

<tr>
<td width="600"><font size="13">
<div align="center"><b>Query</b></div>
</font>
<form name="form1" method="post" action="./file13.php">
<div align="center">
<input type="text" name="query" maxlength="30"></div>
</form></td>
<script type="text/javascript">
document.form1.query.focus();
</script>
<td width="200"><div align="left">Advanced Options;</div>
<form method="post" action="file13.php">
<input type="radio" name="operation" value="radiobutton" checked>
AND<br>
<input type="radio" name="operation" value="radiobutton">
OR
</form></td>
</tr>

<tr></tr>
<tr>
<td><div align="center">
<form method="post" action="file13.php">
<select name="site">
<option>Google</option>
<option>Voyager</option>
<option>ScienceDirect</option>
</select>
</form>
</div></td>
<tag><td>&nbsp;</td></tag?>
</tr>
<tr>
<td><form method="post" action="file13.php">
<div align="center">
<input type="submit" name="Submit" value="submit">
</div>
</form></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>



and this is the php:

<html>
<head><title></title></head>
<body>
<?php
echo "Searhing For ".$_POST['query'];
echo "Searhing For ".$_POST['operation'];
echo "Searhing For ".$_POST['site'];
?>
</body>
</html>




im trying to store the variables into a text file. i would of posted earlier but we had quite a savage power cut!!! things arnt looking up. ;(
cheers for your help!!!

zaichik 01-23-2005 08:13 AM

Hi there,

Add something like:
Code:

<?php

$fd = fopen( "myFile.txt", "a" );
fputs( $fd, $_POST['query'] );
fputs( $fd, $_POST['operation'] );
fputs( $fd, $_POST['site'] );
fclose( $fd );

?>


fopen() opens a file, here it is in append mode so it will add to the bottom of the file. If you called
Code:

fopen( "myfile.txt", "w" );
it would be opened for write, and the current contents of the file would be erased.

HTH.

trscookie 01-24-2005 06:36 AM

you legend!! thank you so much for your help!


All times are GMT -5. The time now is 08:35 AM.