Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question PHP Webpage Inputting HELP!!

    I had a question. First, I am going to start off and say that I am a complete PHP noob lol so bare with me. Anyways, I want to create something where all I do is login to a certain page (i guess sort of like a CMS but only one thing needed), and I can add for example, a business profile page already setup and formatted (templated in html, just missing the variables), all I need to do is add in certain things like a picture or maybe some google maps code for one variable and maybe some other information all in the seperate sections all on this one page. Then when I submit, it takes all of this and creates a .php file named by me in the creation page and uploads it to a certain folder where it is now viewable. How would I go about doing this and what is this called? I just need some basic information on it to research. PHP manual is no help, I figured professional coders like you guys would consider helping me. Its so confusing and if you have anymore questions I will be able to answer them.

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    What you want to do is research the syntax and basics of all major functions. if conditionals, post, get, database setup, connections, etc. w3schools.com will get you around the basics.

    Once you have all that down, coding is just concept. Think of what you want to do, and think of how to do it with the building blocks of knowledge you have.

    For something like that, you'll wanta mysql (or any other databaste) driven website. This might make you want to research basic mysql.

    But you'll have to create two tables.. one for users, the other for profiles.

    I wouldnt create a file itself, I would enter the information, pictures, etc, into the database, then output it via get. You know, how normal profiles (myspace, facebook, etc) profiles are made, they arent physical files.

    http://yoursite.com/profile.php?id=1

    a url like that will show the first profile. On profile.php you'd have code like

    PHP Code:
    $_GET['id'] = (int) $ID// this is the variable in the url profile.php?id={THIS IS WHAT WE'RE GETTING}

    $q mysql_query("SELECT * FROM `profiles` WHERE `id` = $ID");
    $row mysql_fetch_assoc($q); 
    Now.. unless you understand the database design you might be confused. But basically, we're selecting all ROWS from the table named PROFILES, where the id is the id in the URL. So now we can display the data DYNAMICALLY based on the url.

    So, if the rows in the table for profiles are like

    Id
    Name
    Age
    Gender

    ID is the row that controls the bottom rows, so if we selected row 1 it would be like selected all the data under the first record.

    Code:
    id = 1 | name = john doe | age = 20 | gender = male
    ^so that's the information we selected in the mysql_query in the php code. Now to display it on the profile.php page, we use the mysql_fetch_assoc function to echo out the variables.

    like this

    PHP Code:
    $_GET['id'] = (int) $ID// this is the variable in the url profile.php?id={THIS IS WHAT WE'RE GETTING}

    $q mysql_query("SELECT * FROM `profiles` WHERE `id` = $ID");
    $row mysql_fetch_assoc($q);

    echo 
    "

    <table>
    <tr>
    <td>Name</td><td>$row['name']</td>
    <tr>
    <td>Age</td><td>$row['age']</td>
    </tr>
    <tr>
    <td>Gender</td><td>$row['gender']</td>
    </tr>
    </tr>
    </table>

    "

    So that's the basic structure. And the other things you want, like logins, and the page to input data for the profile im sure others can help with.

    The login system, just add to the "user" table, an ID row (primary key) auto incriminate yadayada, username, and password rows. theres a bunch of tutorials for that kinda thing. Populate it with your username and pass you wanna use to login. Then use some mysql function like mysql_num_rows, and if conditionls to compare if the login n pass are in the database and if they match up. then add a session if they match, and you're logged in. (like i said theres tons of tuts on this)

    the cms type page, just add a form to fill out the info, and once the form is filled insert the data into the profile database table, so it can be displayed on the profile.php page.

    So that's really breif how to do this sort of thing. Learn the basics good, and post here when you get stuck on something or need some help, we can help step by step.
    Last edited by Zangeel; 07-17-2009 at 11:35 PM.

  • Users who have thanked Zangeel for this post:

    Joemoemofo (07-17-2009)

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Man your awesome! Very well constructed answer. Very understandable. I will thoroughly look into and if worst comes to worst I might hit someone up with some dough to finish it out.

  • #4
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Been working on it, and looking through your post and had a few questions and comments. I do not want users (unless if thats for me to logon in the backend and edit or add profiles since its only going to be me). Is that what you meant? Also, how would I go about creating table necessary for my project? Still trying to grasp the knowledge and ability to do all of this at a low budget ha.

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    How much would anyone charge to set this up for me? I am on a real tight budget and I am not smart when it comes to MySQL or PHP plus I don't have the time to piddle around since I have other things to accomplish that I know I can do myself haha. Let me know at joemoemofo@yahoo.com or leave a post.

  • #6
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    I'll send you a PM here on CF.

  • #7
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Alright I decided to give this a shot, and I have all the forms and processing files made, now I'm having trouble displaying it. The information gets entered perfectly into the tables with id auto-incrementing, here's the code of my display file:

    PHP Code:
    <?php 

    mysql_connect
    ("xxxxxxxxxxx""xxxxxxxxxxx""xxxxxxxxxxx"); 
    mysql_select_db("xxxxxxxxxx"); 

    $_GET['id'] = (int) $ID// this is the variable in the url profile.php?id={THIS IS WHAT WE'RE GETTING}

    $q mysql_query("SELECT * FROM `profile` WHERE `id` = $ID");
    $row mysql_fetch_assoc($q);

    echo 
    "

    <table>
    <tr>
    <td>Name</td><td>$row['name']</td>
    <tr>
    <td>Age</td><td>$row['age']</td>
    </tr>
    <tr>
    <td>Gender</td><td>$row['gender']</td>
    </tr>
    </tr>
    </table>

    "
    ;

    The error comes up saying this when I browse the page:

    Code:
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/46/d2733/htdocs/c/stuff.php on line 15
    Line 15 is the first $row['name']

    What is the problem here? I've tried the "while" loops but I don't think that is what I want. I want to be able to display the contents of any row anywhere in the display file separately.
    Last edited by Joemoemofo; 07-26-2009 at 01:50 AM.

  • #8
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    echo '<table>
    <tr>
    <td>Name</td><td>'.htmlspecialchars($row['name']).'</td>
    </tr>
    <tr>
    <td>Age</td><td>'.htmlspecialchars($row['age']).'</td>
    </tr>
    <tr>
    <td>Gender</td><td>'.htmlspecialchars($row['gender']).'</td>
    </tr>
    </table>';

  • #9
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    now its just give my

    PHP Code:
    $ID $_GET['id']; 
    trouble by saying "Parse error: syntax error, unexpected T_STRING in blah blah/format.php on line 10"

  • #10
    New Coder
    Join Date
    Jan 2009
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    fixed it... nvm


  •  

    Posting Permissions

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