Clan Adverts

Custom PHPNuke Scripts

 

www.clan-themes.co.uk :: View topic - PHP Question

 Welcome To Clan Themes 

As the board grows please remember the Search Option and we hope you find our community useful.

We also monitor Private Messages to stop members from abusing our sites system.
If you are asking for assistance please provide your site link and nuke version, Thanks.

PHP Question

6 Replies / 524 Views


Post new topic   Reply to topic  

   www.clan-themes.co.uk Forum Index » General Topics

View previous topic :: View next topic


Falgern
Reputation: 0.2
Local time: 7:53 PM


Status: Offline
0.02 posts per day
Medals: 0

Joined: May 09, 2008
Last Visit: 19 May 2008
Posts: 2
Points: 45 

Post PHP Question Posted: Fri May 09, 2008 7:19 pm   

Hello Clan-Themes.co.uk
I've got a bit of PHP problem.
I'm trying to make a page that updates a row in a database. and another page reads from that row and gets its text from it.. some kind of easy posting/updating system.
But i've run into some really big problem.

Code:
<?php
$submit = $_POST['submit'];
$text = $_POST['text'];

$db = mysql_connect(localhost, ******, *****);
mysql_select_db(******);

if ($submit) {
$result = mysql_query("UPDATE pages SET lol = $_POST[text] WHERE id = '1'" );


} else{
?>
<form action="indexupdate.php" method="post">
Text <input type="text" name="text" size="30" style="width: 300px; height: 100px;">


<p><INPUT TYPE="Submit" name="submit" value="Change">

<?php
$submit = $_POST['submit'];
$lname = $_POST['text'];
} // end if
?>


Thats the code i've done so far. but it doesnt work, i cant however see anything wrong in it.

also, is there an easy way to make a page to read from database?


Thank you.
 

 
View user's profileSend private message Reply with quote

stipher
Reputation: 0.2
Local time: 7:53 PM


Status: Offline
0.02 posts per day
Medals: 0

Joined: May 09, 2008
Last Visit: 09 May 2008
Posts: 2
Points: 42 

View user's profileSend private message Reply with quote

Bayler
Reputation: 748.3
votes: 9
Local time: 7:53 PM

usa.gif

Status: Offline
0.99 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 01, 2007
Last Visit: 20 Aug 2008
Posts: 310
Points: 6636 

Post PHP Question Posted: Sat May 10, 2008 2:13 am   

from what i can understand of your question....

im gonna have to break your code into parts to better explain...

Lets start with submitting data to the 'next page' part....
Resource link: http://www.w3schools.com/PHP/php_get.asp

I do NOT recommend the $_GET variable as your data is submitted directly into the URL which can give away information that ultimatly opens the door for injection exploits. Use the ( $_REQUEST ) variable instead.


As for your ( else and If ) statements, i would suggest separating them by 'CASE - Breaks'
Inside of those Case/Breaks insert your function directly into the appropriate function needed.

With SQL. your on the right Track ( INSERT ) is whats needed to add data to your SQL database...
But with the limited information provided in your question..its going to be difficult to point you in the right direction

If you would like further help, your going to need to provide detailed information in your question.
 

You will not recieve help from me if i have to go digging for your CMS information and version, If i have to take the time to play 21 questions, then you can take the time to google! No Copyright, no support either!  
View user's profileSend private messageMSN Messenger Reply with quote

Falgern
Reputation: 0.2
Local time: 7:53 PM


Status: Offline
0.02 posts per day
Medals: 0

Joined: May 09, 2008
Last Visit: 19 May 2008
Posts: 2
Points: 45 

Post PHP Question Posted: Sat May 10, 2008 5:34 am   

Thanks for the reply. I'll try to explain it a bit better

I'm trying to do a page, wich got an text are, the stuff you enter there should get posted into a row in database,
another page reads from that row and post it on the page. so it would become some kind of simple posting system/admin system for my pages. Retard


or is there any easier way to update/change the content of my pages online and not having to change the code itself
 

 
View user's profileSend private message Reply with quote




Bayler
Reputation: 748.3
votes: 9
Local time: 7:53 PM

usa.gif

Status: Offline
0.99 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)

Joined: Nov 01, 2007
Last Visit: 20 Aug 2008
Posts: 310
Points: 6636 

Post PHP Question Posted: Sat May 10, 2008 11:36 am   

ok...

That is no more information then the original question...so i guess your going to make me ask a billion & one questions....

1) What type of CMS are you using...

2) How many Pages are we talking ? 1, 2, as many as you want to create?

3) How much Text is the database storing ? 255 characters, 500, 1000 ???

There are probably going to be more questions...
 

 
View user's profileSend private messageMSN Messenger Reply with quote

Duck
Reputation: 472.4
Local time: 10:53 AM

blank.gif

Status: Offline
0.08 posts per day
Medals: 0

Joined: Jan 07, 2007
Last Visit: 26 Jul 2008
Posts: 50
Points: 5042 

Post PHP Question Posted: Sat May 10, 2008 6:44 pm   

Ok there looks to be a bunch of points to make here. Since you don't wish to include the nuke DB connection class and choose to do the connection manually I would say I would change your routine to this:

Code:
<?php
$submit = $_POST['submit'];
$text = $_POST['text'];

$db = mysql_connect(localhost, ******, *****);
mysql_select_db("Your_DBNAME",$db);

if ($submit) {
$result = mysql_query("UPDATE pages SET lol = $text WHERE id = '1'", $db );


} else{
?>
<form action="indexupdate.php" method="post">
Text <input type="text" name="text" size="30" style="width: 300px; height: 100px;">


<p><INPUT TYPE="Submit" name="submit" value="Change">

<?php
$submit = $_POST['submit'];
$lname = $_POST['text'];
} // end if
?>


Of course I would not recommend your Variable names cause some of them are reserved already if you are using Nuke like $db and $lname
 

 
View user's profileSend private messageMSN Messenger Reply with quote

floppy
Reputation: 2252.7
votes: 10
Local time: 7:53 PM
Location: Jackson Mississippi
usa.gif

Status: Offline
3.06 posts per day
Medals: 1 (View more...)
Dedicated User (Amount: 1)
Clan Themes Scripts/Coder
Clan Themes Scripts/Coder
Joined: Nov 14, 2006
Last Visit: 08 Sep 2008
Posts: 2033
Points: 27650 

Post PHP Question Posted: Sat May 10, 2008 7:08 pm   

Shop Purchases:
Clan Roster 2.0

I don't have much to add, seems these guys got it covered. However I don't see where you closed your form.

Code:
</form>
 

Free Clan Links - Submit Yours today  
View user's profileSend private messageVisit poster's website Reply with quote
Post new topic   Reply to topic  
   www.clan-themes.co.uk Forum Index » General Topics


 
6 Replies / 524 Views
Page 1 of 1
All times are GMT
Display posts from previous:   
 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum