Re: Put value directly into form?
| From: | Phil Latio | Date: | Tue, 14 Aug 2001 15:40:59 +0000 |
| Subject: | Re: Put value directly into form? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62660@lists.php.net to get a copy of this message | ||
> http://www.yorkshire-search.co.uk/links/add.php3
Right, I seem to have not made myself too clear so I'll try again.
Originally, the page "add.php3" was using a plain HTML template called
"add_form.html" which consisted of a simple form. If you click on the link
above and have a look at the page, everything below Add Link was how it
started off. In the code below, it's everything after the </php> tag. Users
would just complete the form and press submit.
However, I decided instead of typing in certain fields, I wanted to autofill
the boxes so I found a PHP4 script which would grab meta-tags and embedded
it into the template. All PHP scripts have to be within <php></php> tags as
defined in a different part of the search engine script.
My problem is that whatever method I have tried, I have not managed autofil
the forms text boxes with values from the script in a one step process.
I first tried putting the HTML form in the script but this brought parsing
errors. Next I tried keeping the form in the HTML but trying to use
value=<?....?> statement. This again brought parsing errors or the code
simply appeared in the box.
Hope that makes a bit more sense.
<table width="100%" cellpadding=3 cellspacing=1 height=23 border=0
text=#000000 link=#FFFFFF></table>
<php>
// Include the function so you can use it later in the page
require('metaengine.php');
// Call the MetaEngine function and assign the return value to an array
$metaInfo = MetaEngine($url);
// Array index is not numbers but names, such as:
// $metaInfo[title] is the title of the page
// $metaInfo[description] is the description of the page
// $metaInfo[keywords] is the keywords of the page
echo "
<html>
<head>
<title>Sample</title>
</head>
<body>
<form method=\"POST\" action=\"$PHP_SELF\">
<CENTER><font face=\"Arial\" size=\"2\"><b>Enter
URL:</b></font> <input
type=\"text\" name=\"url\" size=\"25\">  <input
type=\"submit\"
value=\"Submit\" name=\"B1\"></CENTER><br><font
face=\"Arial\"
size=\"2\"><b>1. Press the submit button and it will grab meta tags of
website.</b></font><br><hr>
</form>
<FORM METHOD=POST ACTION=\"add.php3\">
<input type=hidden name=title value=\"$metaInfo[title]\">
<input type=hidden name=url value=\"$url\">
<input type=hidden name=description value=\"$metaInfo[description]\">
<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\"
width=\"100%\">
<tr>
<td><center><input type=submit name=submit value=\"Now press this
button\" class=\"button\"></center><br><font
face=\"Arial\" size=\"2\"><b>2.
If complete URL displays in box below, press the above
button.</b></font><br><hr></td>
</tr>
</table>
</FORM>
</body>
</html>
";
</php>
<p class="ptitle">Add Link</p>
<table width="500" border="0" cellpadding="5">
<tr>
<td colspan="3">
<center>
<font face="Arial" size="2"
color="Red"><%error_msg%></font>
</center>
<form action="add.php3" method=post>
<input type=hidden name=pflag value=add>
<table border="0" cellspacing="0" cellpadding="4"
width="100%">
<tr>
<td><font face="Arial"
size="2">Url</font></td>
<td><input type="text" name="title" size=20
value="<?=$title?>">
</td>
</tr>
<tr>
<td><font face="Arial"
size="2">Title</font></td>
<td><input type=text name=title size=40
value="<%title%>"></td>
</tr>
<tr>
<td valign="top"><font face="Arial"
size="2">Description</font></td>
<td><textarea name="description" cols="40"
rows="10"
maxlength="255"
wrap="virtual"><%description%></textarea></td>
</tr>
<tr>
<td><font face="Arial"
size="2">Category</font></td>
<td><font face="Arial"
size="2"><%category%></font></td>
</tr>
<tr>
<td><font face="Arial" size="2">Contact
Name</font></td>
<td><input type=text name=contact_name size=30
value="<%contact_name%>"></td>
</tr>
<tr>
<td><font face="Arial"
size="2">Email</font></td>
<td><input type=text name=email size=30
value="<%email%>"></td>
</tr>
<tr>
<td><font face="Arial"
size="2">Bid</font></td>
<td><input type=text name=bid size=10 value="<%bid%>">
<font face="Arial" size="2"
color="green">(optional)</font>
</td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=submit value="Add"
class="button"><br>Once you are happy with your entries, press this
button.</td>
</tr>
</table>
</form>
</td>
</tr>
</table>