Jump to content

redarrow

Members
  • Posts

    7,306
  • Joined

  • Last visited

Posts posted by redarrow

  1. Slap this on the page we want the result posted for statistics.

     

    <?php
    
    function get_execution_time()
    {
        static $microtime_start = null;
        if($microtime_start === null)
        {
            $microtime_start = microtime(true);
            return 0.0;
        }   
        return microtime(true) - $microtime_start;
    }
    get_execution_time();
    ?>
    

  2.  

    I was playing around, and fort this might help you, in your progress.

     

    it only a rough example of making a order at a cafe.

     

    can be well extended.

     

    <?php session_start();
    
    $order_id=rand(11111,5);
    
    $_SESSION['order_id']=$order_id;
    
    if($_POST['submit']){
        
    echo "<b>MY LIITLE CAFE!</b> <br><br>";
        
    $burger=$_POST['burger'];
        
      echo "Order id: ".$_SESSION['order_id']."  <br><br>";
          
          echo "Order information <br><br>";
    
    foreach($burger as $burger){
        
        if("checked"){
           
         switch($burger){
            
            case "burger1":
            
            echo" $burger \n image 1 <br>";
            
            break;
            
            case "burger2":
            
            echo" $burger \n image 2 <br>";
            
            break;
            
            case "burger3":
            
            echo" $burger \n image 3 <br>";
            
            break;
            
            case "burger4":
            
            echo" $burger \n image 4";
            
            break;
         } 
            }
        }
        
      echo" <br><br><A HREF='javascript:history.go(-1)'>[Re order]</A>"; 
        
        exit;
    }
    
    
        
    echo"<p><p>";
    
    ?>
    
    
    <form method="post">
    <img src="" />
    <input type="checkbox" name="burger[]" value="burger1" checked="checked" />
    <img src=""/>
    <input type="checkbox" name="burger[]" value="burger2" checked="checked"/>
    <img src=""/>
    <input type="checkbox" name="burger[]" value="burger3" checked="checked" />
    <img src=""/>
    <input type="checkbox" name="burger[]" value="burger4" checked="checked" />
    <br /><br />
    <input type="submit" name="submit">
    </form>
    
    

  3. When i said power, I meant, there no real coding on the page for php to go slow.

     

    when i look at php codes,i also look at the way php is set up, most people think having a sheared host, that it, i am done, and all my code will be fast and safe.

     

    unfortunately because most sheared hosts use so many accounts on one computer there so slow.(to save money and overheads).

     

    Any body that get serious in programming used a dedicated server, there be amazed of the difference and power, from a sheared host.

     

    I still say it the host you got, not your code, there nothing you can do unless you go to the server and add a 3rd part application to make php it self go faster, Zend supply such thing.(that your host problem,

    your currently paying what £5 month what you expect,i pay just under £400 per month so far tilll i grow more big difference as you can see.)

     

     

    Sorry i got no way to make your code go fast .....

     

    maybe a person might come along and have a better idea.

     

    have you tried the code with out using the function it self any luck.

     

     

     

     

  4. html5 is based on canvas for videos and media files <> browser compatibility will take years.(nothing wrong learning html and then xhtml)

     

    xhtml is not dead, that stupid, it a extension of html, and html is the back bone of the internet.

     

    also

     

    You can learn ajax without learning all the aspects of JavaScript, even thu javascript is the backbone of ajax  but you just learn the DOM and basics.

     

    w3schools , show you example with a .php3, because the internal workings of the script that is used on w3schools, is configured to see .php3 as normal .php files.

     

    There currently running 5.8 php system

     

    there no code on w3school that wrong and is cheeked frequently even universities use that web site.

     

  5. Try this for a example might work.

     

    Warning all the information needs validating........

     

    <?php
    include("dbconnect.php");
    
    if ($_POST['submit'] == "Sign") {
    
    $name=$_POST['name'];
    $location=$_POST['location'];
    $email=$_POST['email'];
    $url=$_POST['url'];
    $comments=$_POST['comments'];
    
    $query = "insert into DA_guestbook(name, location, email, url, comments) values ('$name', '$location', '$email', '$url', '$comments')";
    mysql_query($query) or die (mysql_error());
    ?>
    <h2>Thanks!!</h2>
    <h2><a href="view.php">View my guestbook!</a></h2>
    <?php
    }
    else {
    include("sign.php");
    }
    ?>
    

     

     

     

    <h2>Sign my guestbook</h2>
    <form method="post" action="create_entry.php">
    <b>Name:</b>
    <input type="text" size="40" name="name">
    </br>
    <b>Location:</b>
    <input type="text" size="40" name="location">
    </br>
    <b>Email:</b>
    <input type="text" size="40" name="email">
    </br>
    <b>Home Page Url:</b>
    <input type="text" size="40" name="url">
    </br>
    <b>Comments:</b>
    <textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea>
    </br>
    <input type="submit" name="submit" value="Sign">
    <input type="reset" name="reset" value="Start Over">
    </form>
    

  6. I needed to use a news application provided from a web site of that news web page.

     

    Unfortunately creating a rss feed or scrapping the information my self, will display horrible unless i use there own  news application to show on my web site.

     

    unreal.

     

    Also according to the terms and condition of the news website, i will be prosecuted if i use there information without it going thu there own application.

     

    all about ads and money buggers lol

     

     

  7. you need to add all your name references to post the variables

     

     

    
    <?php
    
    if($_POST['submit']){
    $name=$_POST['name'];
    $location=$_POST['location'];
    
    // do what ever with the posted variables.
    }
    ?>
    

     

    Also i agree, your book out dated, wrong php book version,your studying php 3/4 but using php 5/nearly 6.

  8. You need to understand an id first.

     

    we setup a databse like so

     

    userid ((who the user is))

    name (( user's name

    dob (users date of birth

    tel ((users telephone number

    date ((date a note is made

    time (a time a note is made

    notes (notes))

     

    We give users  a userid in a datadabes, so we no who they are.

     

    lets say a user can comment, on a note a user is showwing.

     

    we need a new database colum for comments.

     

    commentid ((this is the id of the commment

    userid ((this is the person who wrote the comment

    comment ((this is the comment

    noteid(this is the userid of notes

    date_of_note (this is date of note commenting on

    time_of_note((this is time of note commenting on

    date (this is the date of comment

    time ((this is the time of comment

     

    you read a note , and use a link to comment on the note,

    fill in a form to comment, in the form your have hidden values,

    date_of_note and time_of_note, and noteid.

     

    know you can select a specific note, and see comments, form a single user easly.

     

    There more to it, but there the basic idea, to get info about others, or even join info together. via a id...

     

    ----------------

     

    Your jumping before you can walk.

     

    Your trying to create a advance membership system, before knowing how a standard username and password system works.

     

    it simple setup like this

     

    members_power ((table name

     

    member_id (members id from reg)

    member_auth (what the member is 1=admin 2=user)

     

    it  a big clue........

     

     

  9. looking at your code, I see that it the same as php.net.

     

    If you got permission to send a file or use ftp it will happen else not.

     

    A ftp problam is usally the password  or members name .

     

    If you want to advance the code, maybe you need to add some ajax.

     

    you code looks ok , does it work.

     

    Your last else commnd stops un reg users uploding. like  below.

     

    from php.net

    <?php
    $file = 'somefile.txt';
    $remote_file = 'readme.txt';
    
    // set up basic connection
    $conn_id = ftp_connect($ftp_server);
    
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    
    // upload a file
    if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
    echo "successfully uploaded $file\n";
    } else {
    echo "There was a problem while uploading $file\n";
    }
    
    // close the connection
    ftp_close($conn_id);
    ?>
    
    

  10. try this as a mail test

     

    mail.php

    <?php
    $to = 'add you email address here!';
    $subject = 'Wakeup bob!';
    $message = '<b>yo</b>, whassup?';
    $headers = "From: server@example.com\r\n" .
            'X-Mailer: PHP/' . phpversion() . "\r\n" .
            "MIME-Version: 1.0\r\n" .
            "Content-Type: text/html; charset=utf-8\r\n" .
            "Content-Transfer-Encoding: 8bit\r\n\r\n";
    
    // Send
    mail($to, $subject, $message, $headers);
    ?>
    

     

    create a page called mail.php, add you email to the above code,see if it works.

     

    if it work use this code ok.

     

    I am not sure, but i think it the code you posted,  No header info, Mail server's hate that.

     

    Also, had a quick look at your code, you need to valadate the info before entering the database.

     

    also all varables need .

     

    mysql_real_escape_string(['varable_name']) <<< around them.

     

    also you need to add at the bgining of you code.

    if(isset($_POST['submit])){

    }

     

    good luck bro.

  11. The exec() commands you learn as you go along , there millons off examples on google.

     

    Were here to teach you things wrong with your code , but not to write your code and teach you online like a school or collage.

     

     

    go here.

     

    http://www.php.net

    http://www.w3schools.com/php/default.asp

    http://www.tizag.com/phpT/

     

     

    my code.

     

    <?php
    
    /**
    * @author john 
    * @copyright 2011
    */
    
    
    if(isset($_POST['submit'])){
    
    exec('shutdown -s -t ' . intval($_POST['shut']) . ($_POST['shut'] ? ' -f' : ''));
    }
    
    ?>
    
    <center>
    
    <form method="POST" action=" ">
    
    <b>WHEN SHOULD I SHUT DOWN MY PC!</b>
    
    <select name="shut">
    
    <?php
    
    for($i=1; $i<10; $i++){
    
    echo"<option value='$i'>$i<option>";
    }
    
    ?>
    
        
    </select>
    
    <input type="submit" name="submit" value="Shut me down when!">
    
    </center>
    

     

    I had the inpression, you wanted a code to turn you pc off , not to teach you php like a online school.

     

    www.amazon.co.uk

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.