[PHP] Re: Put value directly into form?
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=#00 link=#FF/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 titleSample/title /head body form method=\POST\ action=\$PHP_SELF\ CENTERfont face=\Arial\ size=\2\bEnter URL:/b/font input type=\text\ name=\url\ size=\25\#32;#32;input type=\submit\ value=\Submit\ name=\B1\/CENTERbrfont face=\Arial\ size=\2\b1. Press the submit button and it will grab meta tags of website./b/fontbrhr /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 tdcenterinput type=submit name=submit value=\Now press this button\ class=\button\/centerbrfont face=\Arial\ size=\2\b2. If complete URL displays in box below, press the above button./b/fontbrhr/td /tr /table /FORM /body /html ; /php p class=ptitleAdd 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 tdfont face=Arial size=2Url/font/td tdinput type=text name=title size=20 value=?=$title? /td /tr tr tdfont face=Arial size=2Title/font/td tdinput type=text name=title size=40 value=%title%/td /tr tr td valign=topfont face=Arial size=2Description/font/td tdtextarea name=description cols=40 rows=10 maxlength=255 wrap=virtual%description%/textarea/td /tr tr tdfont face=Arial size=2Category/font/td tdfont face=Arial size=2%category%/font/td /tr tr tdfont face=Arial size=2Contact Name/font/td tdinput type=text name=contact_name size=30 value=%contact_name%/td /tr tr tdfont face=Arial size=2Email/font/td tdinput type=text name=email size=30 value=%email%/td /tr tr tdfont face=Arial size=2Bid/font/td tdinput type=text name=bid size=10 value=%bid% font face=Arial size=2 color=green(optional)/font /td /tr tr tdnbsp;/td tdinput type=submit name=submit value=Add class=buttonbrOnce you are happy with your entries, press this button./td /tr /table /form /td /tr /table -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Put value directly into form?
How can I directly put values into a form instead having to create hidden fields and drag the data from them? You can see what I mean at: http://www.yorkshire-search.co.uk/links/add.php3 Would a javascipt function be any use to me? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] $PHP_SELF in a template problem, I think ??
I run a small search engine and adding URL's is a bit of a pain so I thought I would try to make it easier. Looking around I found a PHP function called get_meta_tags which unsurprisingly, grabs the contents of varoius meta tags. I just want the description contents so I first made a standalone PHP page (http://www.yorkshire-search.co.uk/links/meta-tags.php3) which performs get_meta_tags and uses $PHP_SELF so output is displayed on a page with the same name. Check it out and you see that works fine (was a slight problem if no initial URL value set). However, the search engine uses HTML templates and that is where my problem is. Within the orginal form (add_form.html) was just HTML so I deleted that and put the above working code between php/php tags to generate a form. WhenI uploaded it and then entered the page, the form displayed OK but when I press generate meta tags it refuses to output the results into the boxes. The search engine manual says you can place PHP code within templates as long as they are within php/php tags so I am now at a bit of loss. This is the add_form.html template if anyone is interested. p class=ptitleAdd 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 php if ($action == generate) { print PInsert the following HTML code between the lt;HEADgt; tags of your site:; print FORMTEXTAREA ROWS=8 COLS=60LT;META NAME=\description\ CONTENT=\$desc\GT;\n; print LT;META NAME=\keywords\ CONTENT=\$keyw\GT;\n; if ($robots == yes) { print LT;META NAME=\robot\ CONTENT=\$robotsoption\GT;\n; } if ($refresh == yes) { print LT;META NAME=\refresh\ CONTENT=\$refreshafter\GT;\n; } if ($copyright == yes) { print LT;META NAME=\copyright\ CONTENT=\$copyrighttext\GT;\n; } if ($author == yes) { print LT;META NAME=\author\ CONTENT=\$authorname\GT;\n; } if ($generator == yes) { print LT;META NAME=\generator\ CONTENT=\$generatorname\GT;\n; } if ($language == yes) { print LT;META NAME=\language\ CONTENT=\$languagetype\GT;\n; } if ($revisit == yes) { print LT;META NAME=\revisit-after\ CONTENT=\$revisitdays\GT;\n; } print /TEXTAREA/FORM; print A HREF=\$PHP_SELF\Create another set of meta tags/AP; } else { if (isset($getmetafrompage)) { $MetaTags = get_meta_tags($getmetafrompage); } $description = $MetaTags[description]; $keywords = $MetaTags[keywords]; $robot = $MetaTags[robot]; $author = $MetaTags[author]; $refresh = $MetaTags[refresh]; $copyright = $MetaTags[copyright]; $revisit = $MetaTags[revisit-after]; $generator = $MetaTags[generator]; $language = $MetaTags[language]; $year = date('y'); print FORM ACTION=\$PHP_SELF\ METHOD=post; print If your page already has META tags you may import and edit them.BR; print BURL:/B INPUT TYPE=text NAME=getmetafrompage SIZE=30 VALUE=\http://\;BR; print INPUT TYPE=submit VALUE=\Import META tags from page\ class=\button\/FORMHR; print form action=\add.php3\ method=post; print input type=hidden name=pflag value=add; print table border=\0\ cellspacing=\0\ cellpadding=\4\ width=\100%\tr tdfont face=\Arial\ size=\2\Title/font/tdtd; print input type=text name=title size=40/td/trtrtdfont face=\Arial\ size=\2\Url/font/tdtd; print input type=text name=url size=40 echo=\$getmetafrompage\/td/trtrtd valign=\top\font face=\Arial\ size=\2\Description/font/tdtd; print textarea name=\description\ cols=40 rows=10 maxlength=255 wrap=virtual VALUE=\$description\/textarea; print /td/trtrtdfont face=\Arial\ size=\2\Category/font/tdtdfont face=\Arial\ size=\2\%category%/font/td/trtrtdfont face=\Arial\ size=\2\Contact Name/font/tdtd; print input type=text name=contact_name size=30/td/trtrtdfont face=\Arial\ size=\2\Email/font/tdtdinput type=text name=email size=30/td/trtrtdfont face=\Aria\ size=\2\Bid/font/tdtd; print input type=text name=bid size=10font face=\Arial\ size=\2\ color=\green\(optional)/font/td/trtrtdnbsp;/tdtdinput type=submit name=submit value=\Add\ class=\button\/td/tr/table/form; } /php /td /tr /table -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $PHP_SELF in a template problem, I think ??
Tried this and got parsing errors so php/php must be correct. Richard Baskett [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Does the manual actually say to use the tags php/php? Or is it the normal tags of ?php ?? I run a small search engine and adding URL's is a bit of a pain so I thought I would try to make it easier. Looking around I found a PHP function called get_meta_tags which unsurprisingly, grabs the contents of varoius meta tags. I just want the description contents so I first made a standalone PHP page (http://www.yorkshire-search.co.uk/links/meta-tags.php3) which performs get_meta_tags and uses $PHP_SELF so output is displayed on a page with the same name. Check it out and you see that works fine (was a slight problem if no initial URL value set). However, the search engine uses HTML templates and that is where my problem is. Within the orginal form (add_form.html) was just HTML so I deleted that and put the above working code between php/php tags to generate a form. WhenI uploaded it and then entered the page, the form displayed OK but when I press generate meta tags it refuses to output the results into the boxes. The search engine manual says you can place PHP code within templates as long as they are within php/php tags so I am now at a bit of loss. This is the add_form.html template if anyone is interested. p class=ptitleAdd 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 php if ($action == generate) { print PInsert the following HTML code between the lt;HEADgt; tags of your site:; print FORMTEXTAREA ROWS=8 COLS=60LT;META NAME=\description\ CONTENT=\$desc\GT;\n; print LT;META NAME=\keywords\ CONTENT=\$keyw\GT;\n; if ($robots == yes) { print LT;META NAME=\robot\ CONTENT=\$robotsoption\GT;\n; } if ($refresh == yes) { print LT;META NAME=\refresh\ CONTENT=\$refreshafter\GT;\n; } if ($copyright == yes) { print LT;META NAME=\copyright\ CONTENT=\$copyrighttext\GT;\n; } if ($author == yes) { print LT;META NAME=\author\ CONTENT=\$authorname\GT;\n; } if ($generator == yes) { print LT;META NAME=\generator\ CONTENT=\$generatorname\GT;\n; } if ($language == yes) { print LT;META NAME=\language\ CONTENT=\$languagetype\GT;\n; } if ($revisit == yes) { print LT;META NAME=\revisit-after\ CONTENT=\$revisitdays\GT;\n; } print /TEXTAREA/FORM; print A HREF=\$PHP_SELF\Create another set of meta tags/AP; } else { if (isset($getmetafrompage)) { $MetaTags = get_meta_tags($getmetafrompage); } $description = $MetaTags[description]; $keywords = $MetaTags[keywords]; $robot = $MetaTags[robot]; $author = $MetaTags[author]; $refresh = $MetaTags[refresh]; $copyright = $MetaTags[copyright]; $revisit = $MetaTags[revisit-after]; $generator = $MetaTags[generator]; $language = $MetaTags[language]; $year = date('y'); print FORM ACTION=\$PHP_SELF\ METHOD=post; print If your page already has META tags you may import and edit them.BR; print BURL:/B INPUT TYPE=text NAME=getmetafrompage SIZE=30 VALUE=\http://\;BR; print INPUT TYPE=submit VALUE=\Import META tags from page\ class=\button\/FORMHR; print form action=\add.php3\ method=post; print input type=hidden name=pflag value=add; print table border=\0\ cellspacing=\0\ cellpadding=\4\ width=\100%\tr tdfont face=\Arial\ size=\2\Title/font/tdtd; print input type=text name=title size=40/td/trtrtdfont face=\Arial\ size=\2\Url/font/tdtd; print input type=text name=url size=40 echo=\$getmetafrompage\/td/trtrtd valign=\top\font face=\Arial\ size=\2\Description/font/tdtd; print textarea name=\description\ cols=40 rows=10 maxlength=255 wrap=virtual VALUE=\$description\/textarea; print /td/trtrtdfont face=\Arial\ size=\2\Category/font/tdtdfont face=\Arial\ size=\2\%category%/font/td/trtrtdfont face=\Arial\ size=\2\Contact Name/font/tdtd; print input type=text name=contact_name size=30/td/trtrtdfont face=\Arial\ size=\2\Email/font/tdtdinput type=text name=email size=30/td/trtrtdfont face=\Aria\ size=\2\Bid/font/tdtd; print input type=text name=bid size=10font face=\Arial\ size=\2\ color=\green\(optional)/font/td/trtrtdnbsp;/tdtdinput type=submit name=submit value=\Add\ class=\button\/td/tr/table/form; } /php /td /tr /table -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] What's the difference between echo and print?
What's the difference between echo and print? I believed they were the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Does $PHP_SELF work in templates?
Lets take the most simple of scripts and run it on a standalone page to prove it's working correctly before we import into a template file. http://www.yorkshire-search.co.uk/links/add_form.php4 Next step, lets change the tags ?php ? to php/php because that's what it says in the manual and put it into the add_form.html template and see if it runs now. http://www.yorkshire-search.co.uk/links/add.php3 Oh dear boys and girls, it doesn't work and poor old Phil is starting to cry. I know, let's play a game and see if we can cheer him up by finding out why the below code doesn't work and of course, you can play along at home too. php { $MetaTags = get_meta_tags($getmetafrompage/,1); { $description = $MetaTags[description]; } print FORM ACTION=\$PHP_SELF\ METHOD=post; print If your page already has META tags you may import and edit them.BR; print BURL:/B INPUT TYPE=text NAME=getmetafrompage SIZE=30 VALUE=\http://\;BR; print INPUT TYPE=submit VALUE=\Import META tags from page\/FORMHR; echo font face=\Arial\ size=\2\ color=\Red\%error_msg%/font; echo form action=\add.php3\ method=post; echo input type=hidden name=pflag value=add; echo textarea name=\description\ cols=\40\ rows=\10\ maxlength=\255\ wrap=\virtual\; echo $description; echo /textareap; echo input type=submit name=submit value=\Add\ class=\button\; echo /form; } /php This is my attempt at humour if anyone was wondering !! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]