1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

PHP 7.1 question?

Discussion in 'Web Design & Development' started by daubydotson, Mar 22, 2018.

Advertisement
  1. daubydotson

    daubydotson Thread Starter

    Joined:
    Mar 17, 2018
    Messages:
    10
    How do I run on my computer, a program I created (I have windows 10)?
     
  2. Sponsor

  3. cwwozniak

    cwwozniak Trusted Advisor

    Joined:
    Nov 28, 2005
    Messages:
    57,277
    First Name:
    Chuck
  4. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    ... You would then be able to run programs using a url similar to this:
    Code:
    http://localhost/my_project/my_program.php
    Where my_project is the directory within the xaamp directory htdocs and my_program.php is obviously, the program you wish to run ...
     
  5. dvk01

    dvk01 Moderator Malware Specialist

    Joined:
    Dec 14, 2002
    Messages:
    54,133
    First Name:
    Derek
  6. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    Yes, and the OP doesn't appear to have opted for a choice - WAMP, XAAMP or DesktopServer - it's "Make your mind up time!"
     
  7. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    Maybe an explanation is in order ...
    Because PHP is a server-side language, we need to emulate what a server does in order to run a PHP program. These three options each provide a server environment, to do this ...
     
    cwwozniak likes this.
  8. daubydotson

    daubydotson Thread Starter

    Joined:
    Mar 17, 2018
    Messages:
    10
    whats wrong with my code? here is the html syntax. trying to create a text file. do I have to create the txt file or does it get created automatically. I am new to php. this html file is called "loadrestauranthtml.html"

    <html>
    <head>
    <title>loadrestauranthtml</title>
    </head>
    <body>
    <h1><center><u><b>restaurant</b></u></center></h1>
    <br>
    <br>
    <form method="post"
    action="loadrestaurantphp.php">
    <input type = "text"
    name = "john1"
    value = ""
    size = "20" />
    <br>
    <br>
    <input type = "submit"
    value = "submit">
    <input type = "reset"
    value = "reset">
    </form>
    </body>
    </html>

    -----------------------------------------------------------------------------------------------------
    this is my php code. I am trying to create a text file called RESTAURANTDATA.TXT.
    is there an easier way to do this. this php is called "loadrestaurantphp.php"


    <html>
    <head>
    <title>loadrestaurantphp</title>
    </head>
    <Body>
    <h1>php load to file</h1> p
    <? php
    $fp = ""
    $fp = fopen("restaurantdata.txt"; "w");
    fclose($fp);
    ?>
    </body>
    </html>
    -------------------------------------------------------------------
    please help! thank you.
    john

    < moderator removed email address >
     
    Last edited by a moderator: Mar 25, 2018
  9. daubydotson

    daubydotson Thread Starter

    Joined:
    Mar 17, 2018
    Messages:
    10
    thank you JiminSA. Your information was very helpful.
    I now know php runs on a server. and also, after you upload your php program you are able to use url to point to the file you created. does that make sense. also, I created a php/html program and upload it to the server. it is suppose to have created a text db. once I create this txt file on the server, how to I read the file/database and view the file.
    the program on the server does not run, and I don't know why. if you now PHP, can you help me with this simple (get my feet wet) program. I'm new to programming php.
    thanks, John
     
  10. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    If you can give us a link to your program online, we can take a look. You might also post the source code, using the "Insert" icon in the "Post Reply" header ...
     
  11. dvk01

    dvk01 Moderator Malware Specialist

    Joined:
    Dec 14, 2002
    Messages:
    54,133
    First Name:
    Derek
    @daubydotson
    you aren't making it easy to help you. Please make all your replies in this topic, not keep starting new ones all over the place.
    I have merged all relevant posts into this one thread.
    Now we can see exactly what the problem is, somebody can hopefully offer the correct advice to you.
     
  12. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    Okay, the reason why your txt file is not being created is because you are not doing a write - (presumably using data collected from the form).
    At the moment you are using 2 separate pages to perform this - it would be more efficient to combine them as one HTML5 .php page. Thus:
    PHP:
    <?php
    if(!isset($_SESSION))
    {
        
    session_start();
    }
    if(isset(
    $_REQUEST['submit']))

        
    $fp ""
        
    $fp fopen("restaurantdata.txt""w") or die("Unable to open file!");
        if(isset(
    $_REQUEST['john1']))
        {
            
    $data $_REQUEST['john1'] . "\n";
            
    fwrite($fp$data);
        }
        else
        {
           die(
    'no post data to process');
        } 
        
    fclose($fp);
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>load restaurant page</title>
    </head>
    <body>
    <h1><u><b>restaurant</b></u></h1>
    <br>
    <br>
    <form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
    <input type = "text" name = "john1" value = "" size = "20" required />
    <br>
    <br>
    <input type = "submit" value = "submit">
    <input type = "reset" value = "reset">
    </form>
    </body>
    </html>
    I have taken out the <center> tag, which is deprecated in HTML5 and put in required for your input field. I have also changed your POST to REQUEST, which also gathers url GET parameters ...
     
    Last edited: Mar 26, 2018
  13. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,168
    First Name:
    Colin
    Jim

    You should not be using
    Code:
    $_SERVER['PHP_SELF']
    it is a security risk.

    You should be using
    Code:
    <form method="post" enctype="multipart/form-data">
     
  14. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,131
    Thanks for the headsup Colin(y) Not that I doubted you, but I was curious as to how and discover that using it can make script vulnerable to Cross Site Scripting injection:(
    So, @daubydotson, please use this revised script - omitting the action= parameter, will make the form default the action page to same page ...
    PHP:
    <?php
    if(!isset($_SESSION))
    {
        
    session_start();
    }
    if(isset(
    $_REQUEST['submit']))
    {
        
    $fp ""
        
    $fp fopen("restaurantdata.txt""w") or die("Unable to open file!");
        if(isset(
    $_REQUEST['john1']))
        {
            
    $data $_REQUEST['john1'] . "\n";
            
    fwrite($fp$data);
        }
        else
        {
           die(
    'no post data to process');
        }
        
    fclose($fp);
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>load restaurant page</title>
    </head>
    <body>
    <h1><u><b>restaurant</b></u></h1>
    <br>
    <br>
    <form method="post" enctype="multipart/form-data">
    <input type = "text" name = "john1" value = "" size = "20" required />
    <br>
    <br>
    <input type = "submit" value = "submit">
    <input type = "reset" value = "reset">
    </form>
    </body>
    </html>
    You may want to consider, using the append+ option on the write (seehere)
     
    Last edited: Mar 26, 2018
  15. daubydotson

    daubydotson Thread Starter

    Joined:
    Mar 17, 2018
    Messages:
    10
    JiminSA-I tried code but still not working. tell me what you need me to supply you with.


    reference this code:(line 9)

    $fp = fopen("restaurantdata.txt"; "w") or die("Unable to open file!");

    NOTE: restaurantdata.txt was created with notepad.
    --------------------------------------------------------------------------
    error message:
    Parse error: syntax error, unexpected '$fp' (T_VARIABLE) in /homepages/21/d728606147/htdocs/
    SeniorsNew/database3.php on line 9

    url address:
    seniors-out-and-about.com/database3.php
    -or-
    seniors-out-and-about.com/database3.htm
    ----------------------------------------------------------------------------
    validation on access to db731443068.

    seniors-out-and-about.com/connect.php

    ----------------------------------------------------------------------------
    questions:
    1) does the php code go inbetween the <body> tags?
    2) the database file was created in notepad as '
    restaurantdata.txt' and uploaded to the server.(1and1.com)
    no records are in it.
    3) using the create database in 1and1 control panel, I
    created a database file called: db731443068 but, I don't
    know how to reference it or to save data to it. what
    should I do?
    ----------------------------------------------------------------------------
    please help. thank you
    john
    [daubydotson]
     
  16. dvk01

    dvk01 Moderator Malware Specialist

    Joined:
    Dec 14, 2002
    Messages:
    54,133
    First Name:
    Derek
    How many times do we have to tell you
    stop making new topics and reply to the original topic.
    Moved this one as well!
     
  17. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...

Short URL to this thread: https://techguy.org/1207222

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice