Help is needed :) Php code for phone book

Discussion in 'PHP' started by nedamear, Aug 12, 2007.

  1. #1

    hello everybody:
    how's it going? this is my first entery in here, and i really enjoyed lots of your subjects. WAY TO GO GUYS. im very much indeed beginner in PHP language and i found this task that i found it interesting since it's limits the chars you have to use
    i've tried to make a code , but i guess i failed, so i wonder if you guys would HELP ME OUT PLEAssssssssssssSSSSE. :)
    Thx in advance :

    Create Website phone address book include home page which include menu

    has two link (add new field,view persons)
    add new field go to the page include register form have this field

    1) First Name (text field 25 char)
    2) Mid Name (text field 25 char)
    3) Last Name (text field 25 char)
    4) Country (list menu)
    5) City (text field 25 char)
    6) Telephone (text field 25 char)
    7) Email (text field 50 char)
    8) Date Register (text field 10 char)
    9) Status (radio group 1 enable 0 disable )


    after click submit this fields save into file phone.txt

    second link in the home page (view persons) go to see all persons with his
    all informations inside table like this (Read from file phone.txt ) :
     
    nedamear, Aug 12, 2007 IP
  2. web_dev

    web_dev Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nedamear, the phone book php application/website will require more coding than you think and it would involves saving the data into a database as well. I don't recommend saving the info in flat text file, rather use a database. It will be much easier to insert, delete or update data from database than from a flat file. Plus flat files would be rather unsecured to use.

    You can look at some tutorials on the net how to create form processing in PHP. You also need to create a database to insert the person's info into the table once they fill out the form.

    If you like you can PM me and i can help you create the site properly.
     
    web_dev, Aug 12, 2007 IP
  3. nedamear

    nedamear Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hay web dev , thx for your time, :)
    i've already done the form
    in phone.html page
    <table width=80% align="center">
    <form action="phone.php" method="post"><br>
    <tr><td>First Name: <input type="text" name="first" /><br></td></tr>
    <tr><td>Mid Name: <input type="text" name="mid" /><br></td></tr>
    <tr><td>Last Name: <input type="text" name="last" /><br></td></tr>
    <tr> <td colspan="2">Country
    <select name="country">
    <option value="1">Palestine</option>
    <option value="2">Jordan</option>
    <option value="3">Egypt</option>
    </select></td>
    </tr><br>
    <tr><td>City: <input type="text" name="city" /><br></td></tr>
    <tr><td>Telephone: <input type="text" name="phone" /><br></td></tr>
    <tr><td>Email: <input type="text" name="email" /><br></td></tr>
    <tr><td>Data Register: <input type="text" name="data" /><br></td></tr>
    <tr><td>Status: <input type="text" name="status" /><br></td></tr>
    <tr><td><input type="submit" /><br></td></tr>
    </form>
    but i don't know how to send the info to phone.php just quite right
    i've used this code $_POST thing, this is what i found on one of tutorials .
    well i guess i'm not usein it right :)
    <?
    $_POST["name"]. echo "welcome";

    ?>
     
    nedamear, Aug 12, 2007 IP
  4. web_dev

    web_dev Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you're on track but you're accessing the person's name wrong. Look at hos you defined in your html

    First Name: <input type="text" name="first" />

    So, instead $_POST["name"], it should be $_POST["first"]. This will give you the first name of the person who filled out the form.
     
    web_dev, Aug 12, 2007 IP
  5. nedamear

    nedamear Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    :)
    i've tried this one :

    Welcome <? echo $_POST["first"];?>.<br />
    You are from<? echo $_POST["country"]; ?>
    You are <? echo $_POST["status"]; ?>

    but i browse it all i got is this

    Welcome
    Notice: Undefined index: first in C:\Apache2\htdocs\New Folder\homework\phone.php on line 10
    .
    You are from
    Notice: Undefined index: country in C:\Apache2\htdocs\New Folder\homework\phone.php on line 11
     
    nedamear, Aug 12, 2007 IP
  6. nedamear

    nedamear Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i've did it. Thx alot Web dev , i wouldn't do it without your help so thx alot
    here's what ive did at phone.php

    <body>

    <? echo "Your First Name is". $_POST['first'];?><BR>
    <? echo "Your Mid Name is".$_POST['mid'];?><BR>
    <? echo "Your last Name is".$_POST['last'];?><BR>
    <? echo "Your Country is".$_POST['country'];?><BR>
    <? echo "Your City is".$_POST['city'];?><BR>
    <? echo"Your Phone Number is". $_POST['phone'];?><BR>
    <? echo "Your Email is".$_POST['email'];?> <BR>
    <? echo "Your Data Registeris".$_POST['data'];?> <BR>
    <? echo "Your Status is".$_POST['status'];?><BR>

    </body>
    </html>

    THAAAAAAAAAAAAANKS ALOT FOR YOUR TIME :)
     
    nedamear, Aug 12, 2007 IP
  7. web_dev

    web_dev Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    i'm glad it worked out for you. happy coding :)
     
    web_dev, Aug 12, 2007 IP