View Full Version : simple problem: setting up a php page
VatsaL
11-08-2006, 01:06 AM
hello all,
I want to set up an input form which takes in a link and when submitted, produces a clickable link.
Much like the one they have on http://isnoop.net/tools/url.php
I found a simlar script:
http://www.totallyphp.co.uk/code/convert_links_into_clickable_hyperlinks.htm
The problem is, Im just good at html and not php, I tried setting up the page with the form and submit, but it didnt work.
How should I set up the php page?
Also, is it possible to have the same function on an .htm file??
thanks
VatsaL
codeexploiter
11-08-2006, 04:18 AM
<?php
$sub = $_POST['submit'];
if($sub == 'submit') {
$url = trim($_POST['url']);
if($url == '') {
echo "<script> alert('Please enter a valid URL to proceed');</script>";
}
}
?>
<html>
<head>
<title>URL Experiment</title>
</head>
<body>
<form name="f1" action="" method="post">
URL: <input type="text" name="url">
<br>
<input type="submit" name="submit" value="submit">
</form>
<br>
<?php
if($url != '') {
echo "<a href=\"$url\" target=\"_blank\">$url</a>";
}
?>
</body>
</html>
You can achieve whatever you want using the above code snippet.
Also, is it possible to have the same function on an .htm file??
It is not possible for you to execute a PHP function from a file whose extension is .htm or .html.
If you want to perform something using PHP then the file extension must be .php. You can insert all the html tags in a PHP file.
How should I set up the php page?
1. You can't open a PHP page by double clicking on it like an HTML page
2. I would suggest to use XAMPP (http://www.apachefriends.org/en/xampp.html). Because the package has Apache webserver, MySQL Database Package, etc as a single installer.
3. You can install them by clicking some two three buttons which is definitely a lot simpler than invidual installation of web server, PHP, etc
4. After the installation of XAMPP (assuming that u r using Windows) you can save your php files inside C:\program files\xampp\htdocs folder which is the default web publishing directory.
5. To view your php file which is in the above mentioned folder open your browser and type http://localhost/thefilename.php
*thefilename.php can be anything you want
*the localhost can be replaced by your machine name
Hope this will help you to start the PHP script running
VatsaL
11-08-2006, 10:24 AM
hi, it dosent seem to work!
Here is the file:
http://labs.50webs.com/hybrid/url.php
VatsaL
codeexploiter
11-08-2006, 11:36 AM
1. Does your site based on a free hosting plan?
2. If yes does your free hosting web server supports PHP?
3. If your web server supports PHP it wouldn't have displayed your entire code in the browser.
Please make sure that the hosting plan/server has PHP scripting support.
VatsaL
11-08-2006, 12:10 PM
3. If your web server supports PHP it wouldn't have displayed your entire code in the browser.
oh! then that explains, ..it dosent!
thanks anyways
VatsaL
codeexploiter
11-08-2006, 12:13 PM
You can check with the support of your hosting provider to make sure their support of PHP.
They support PHP for paid hosting
VatsaL
11-08-2006, 09:50 PM
yeah, they do for paid hosting.
ItsMeOnly
11-08-2006, 09:55 PM
It is not possible for you to execute a PHP function from a file whose extension is .htm or .html.
If you want to perform something using PHP then the file extension must be .php. You can insert all the html tags in a PHP file.
This is very misleading: yes it is possible to parse files with .htm and .html extension or text/html "mime magic header", however the http server must be configured to do so.
as in apache
AddType application/x-httpd-php .php .phtml .html .htm .inc
if your provider has Apache web server, you can create .htaccess file containing this line
codeexploiter
11-10-2006, 04:12 AM
Originally Posted by codeexploiter
It is not possible for you to execute a PHP function from a file whose extension is .htm or .html.
If you want to perform something using PHP then the file extension must be .php. You can insert all the html tags in a PHP file.
I am extremely sorry from the incorrect information from my earlier posting.
ItsMeOnly is absolutely correct regarding executing PHP scripts in the .htm or .html pages.
But this can be done at a hosting provider who supports .htaccess file
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.