Results 1 to 9 of 9

Thread: simple problem: setting up a php page

  1. #1
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation simple problem: setting up a php page

    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/con...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

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    <?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.

    Quote Originally Posted by VatsaL
    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.

    Quote Originally Posted by VatsaL
    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. 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

  3. #3
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hi, it dosent seem to work!

    Here is the file:
    http://labs.50webs.com/hybrid/url.php


    VatsaL

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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.

  5. #5
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by codeexploiter
    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

  6. #6
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You can check with the support of your hosting provider to make sure their support of PHP.

    They support PHP for paid hosting

  7. #7
    Join Date
    Apr 2006
    Location
    London
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yeah, they do for paid hosting.

  8. #8
    Join Date
    Aug 2006
    Posts
    239
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote 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.
    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
    Code:
    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

  9. #9
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Quote Originally Posted by codeexploiter
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •