Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Error with admin panel
Old 05-14-2008, 08:01 AM Error with admin panel
Average Talker

Posts: 28
Name: James
Trades: 0
well ive been trying to make a admin panel where i can change the text on the homepage if you are logged in.
here is my funtion for adding to the database:
Code:
 function addtext(){
      global $session, $database, $form;
	  $q = "INSERT INTO content (text) VALUES ('$_POST[$content]')";
	  $database->query($q);
   }
And here is the code for the form:
Code:
<form action="adminprocess.php" method="post">
content: <input type="text" name="content"/>
<input type="submit" value="add content"/>
</form>
When i put a value into the form and click submit it takes me to admin process.php. and adds a blank entry to the database. No matter what i put into the form it always makes a blank entry.
I tried changing it to just add a set peice of text:
Code:
$q = "INSERT INTO content (text) VALUES ('hello world')";
This works fine and adds hello world to the database.
My database name is 'adminp', my table name is 'content' and my feild is 'text'.
Any help with this would be greatly appreciated.
4o4found is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-14-2008, 08:37 AM Re: Error with admin panel
Average Talker

Posts: 28
Trades: 0
You've just got your strings and variables mixed up a bit.

Change:
"INSERT INTO content (text) VALUES ('$_POST[$content]')";
To:
"INSERT INTO content (text) VALUES ('" . $_POST['content'] . "')";

And everything should be fine.

Last edited by Cory Dee; 05-14-2008 at 08:39 AM..
Cory Dee is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Error with admin panel
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10291 seconds with 12 queries