PHP {Programs}

Discussion in 'Web Design & Coding' started by Techno Child, Apr 28, 2006.

  1. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    I need help coding a few php programs... I am a visual person to where I have to have examples to understand what i'm doing :squareeye

    First, I am trying to create a php script that will process html forms such as this,
    Code:
    <form action="process.php" method="post">
    <input type=text name=textbox>
    </form>
    
    ,to post whatever is submitted in the textbox onto the same php page...

    {this is where i thought i could use agneta's donation recording script - mainframeguy so maybe the best way to go around this is to start with what you had?}

    i just started learning php yesterday so this is all new to me :)


    Thanx
     
  2. Mainframeguy

    Mainframeguy Debiant by way of Ubuntu Folding Team

    Messages:
    3,763
    Location:
    London, UK
    attached the phps... lemme know if any probs
     

    Attached Files:

  3. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    hmm.. is there a reason why apache would make these files forbidden? i cannot access them at all :( ... let me try to reunzip them


    btw.. thanks for uploading them :D
     
  4. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    is there any way i can check to see if i have mysql configured properly? the installer just left me hanging with no further documents or actions to take
     
  5. Mainframeguy

    Mainframeguy Debiant by way of Ubuntu Folding Team

    Messages:
    3,763
    Location:
    London, UK
    mebbe time for a new thread again! Xistence is, I think, something of a MySQL guru... no doubt he'll tell me if I am wrong....
     
  6. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    does apache have read access to the the files and the directory they are in?

    if php cant connect to the database it should complain about it.

    try this though
    Code:
    <?php
    error_reporting(E_ALL);
    mysql_connect('host', 'user', 'password');
    mysql_select_db('database name');
    
    $result = mysql_query("SELECT * FROM {$table_name}");
    while ($row = mysql_fetch_array($result)) {
        echo "Printing Row data\n";
        print_r($row);
        echo "Finished Printing Row data\n";
    }
    ?>
     
  7. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    thanks guys.. i got it worked out last night... i setup everything in php using flat files so i don't really need mysql for a while... (going on 38 hrs. :dead: ) This will also help keep this thread on focus of PHP :)


    My next issue is login. I want to have certain parts of my site only availible to those that i give a key to (such as file upload page for people to send me files) i know htaccess is probably the best way to do this in apache, however I would like to add it to the sidemenu and make it match the site.

    On my last site i had the form for this all setup, however it was very unsecure (using javascript - and the password was actually IN the code!?!)

    Is there a php script that retrieves data from a secure field
    Code:
    <form action="passcheck.php" method="post">
    <input type=text name=username><br>
    <input type=password name=password>
    </form>
    
    such as the one above?
     
  8. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    just use something like

    Code:
    <?
    $password = $_POST['password'];
    echo $password;
    ?>
    
     
  9. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    how would i put mulitple passwords on that? would i just repeat the whole code minus the <?/?>'s? and which password would be replaced with the pages password? ( i really am a php newb as i just started learning it this week :()

    also, it would have to have different redirection pages... is there a way to replace the echo with a page redir?
     
  10. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    ok.... so far i have everything worked out except this.... i can't get this to send an email... i know my server is setup for email because a code worked before i just forgot how i did it...
    maybe this is just messed up---
    Code:
    <?php
    if(isset($_POST['submit'])) {
    $to = $_POST['email'];
    $subject = "New Account";
    $email_field = $_POST['email'];
    $message = "here is the contents of the message";
     
    $body = "$message";
     
    echo "";
    mail($to, $subject, $body);
    } else {
    echo "An error has occured.  Contact the server admin.";
    }
    ?>
     
  11. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    please help someone... this one i have no idea about what's wrong... it doesn't echo "an error has occured~~~" it just loads the rest of the page like normal and it doesn't send out the email...
     
  12. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    you need to put an "if" in
    PHP:
    <?php
    if(isset($_POST['submit'])) {
    $to $_POST['email'];
    $subject "New Account";
    $email_field $_POST['email'];
    $message "here is the contents of the message";
     
    $body "$message";
     
    echo 
    "";
      if(!
    mail($to$subject$body))
      {
      echo 
    "An error has occured.  Contact the server admin.";
      }
    }
    ?>
     
  13. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    it still doesn't work... however now it does give me the error message

    what else could it be? if you need more info about the pages i could upload them for you
     
  14. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    try adding a "from" field, i know some won't send without it

    PHP:
    $to $_POST['email'];
    $subject "New Account";
    $message 'TESTING';
    $headers 'From: webmaster@example.com' "\r\n" .
    'Reply-To: webmaster@example.com' "\r\n" .
    'X-Mailer: PHP/' phpversion();
     
    if(!
    mail($to$subject$message$headers))
    {
    echo 
    "An error has occured. Contact the server admin.";
    }
    if the "mail" function is still not working its probably something todo with you host, perhaps they've broken it recently. The script is working
     
  15. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    still no go... it doesn't send it to me.... i'm going to check and make sure everythings ok with php's config... will let u know



    yep... it's something wrong with the server.... sorry for bugging you guys...i'm going to have fun troubleshooting-the joys of having your own dedicated server :dead:
     
  16. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    ok.... found the problem... it looks like i caused it from the beginning (don't know how it worked even then?!) i was lazy and i just cp/pasted my php.ini file from my ibook onto the g3 since the g3 was a fresh instal and my book was already configured....


    theproblem:= ibook-php5.1; g3-php4.3.4 :dead: now i have to reinstall php on the crapmacg3 so it will work... i hope that was the problem




    EDIT: ok.... i got a php.ini from php4 however it still won't send it... i know the code's good because it works on my ibook, it just won't send on the other comp. i'm going to re-research how to setup php.ini to send mail... it has something to do with unix's sendmail function i think.... idk
     
    Last edited: May 4, 2006
  17. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    let us know when you get it figured. :)
     
  18. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Your Crapmac as you call it is not running a mail server and thus can't send you any email.
     
  19. Techno Child

    Techno Child web{designer} Folding Team

    Messages:
    871
    Location:
    Myrtle Beach
    y? it has a sendmail file in /sbin ... what do I need to do? I thought that was installed with osx - my Ibook sends out emails when I have webserver enabled.

    Is there something extra I need to install for 10.2?
     
  20. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    I have no clue in that case. Hope you find the answer.