Use PHP to add Content to page through Admin

goldy30

New Member
Messages
60
Reaction score
0
Points
0
I'm doing my final website for TAFE but I'm very sketchy on my php. We done it for 2 weeks months ago and haven't used it since. Now I need to start working on my site using php but I have no idea!

Anyway, I want to allow my admin to access a 'manage pages' link and see through a form the content that is displayed from the database.

By entering the title of the page through an input they will alter the title of the page in the front end. They would also be able to add or edit the text on the page through a text area.

Once the information is in the database the content should reflect back into the form fields so admin can see what they are editing.

I have a 'pages' table in the database which consists of 4 fields; pages_id, pagename, title and blurb.

I'd assume I'd have to echo back what is in the database on the page where I want the text to appear.

I'm not sure what other info you need but heres the form.
HTML:
<form action="" method="post" name="">                    
                
                    <table cellpadding="10px" width="400" height="100px" border="0" bordercolor="" cellspacing="0">
                        
                        <tr>
                            <td>
                                Select Page:<br> 

                                <select name="selectpage">
                                    <option value="index">Home</option>
                                    <option value="viewpetition">View Petitions</option>
                                    <option value="startpetition">Start a Petition</option>
                                    <option value="howtopetition">How to write a petition</option>
                                    <option value="resources">Government Resources</option>
                                    <option value="contact">Contact Us</option>
                                    <option value="privacy">Privacy Statement</option>
                                    <option value="about">About Us</option>
                                    <option value="about">New Page</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Title:<br> <input type="text" name="index_title"  size="40">
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Page Info:<br>
                                <textarea name="index_content"  rows="7" cols="60"></textarea><br>
                                
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <input type="image" src="images/save.gif">
                            </td>
                        
                        </tr>
                    </table>

        </form>

I appreciate any help or direction anyone can give me. Playing with this will also get the PHP wheels in my head cranking again.

Thanks.
 

thespeshulk

New Member
Messages
9
Reaction score
0
Points
0
The easiest to do this, if I'm understanding right what it is you're trying to accomplish, to grab the page's content from the database and store it in an associative array. If you are using basic mysql functions this will be something like:
$query="mysql query";
$result=mysql_query($query);
$row=mysql_fetch_assoc($result);
This will return an array with the indexes as the fields and the values as the content associated with the field.

When you submit the form you will probably want to send the data to a php file that will process the information and update the database. if you have any questions on a mysql function just google mysql and the function or the action you want to do and you should get good results. As for the PhP side try checking out php.net for a list of all of php's functions. (its how i got started =) )
 
Top