Jump to content

Recommended Posts

[!--quoteo(post=356858:date=Mar 20 2006, 11:48 PM:name=XTTX)--][div class=\'quotetop\']QUOTE(XTTX @ Mar 20 2006, 11:48 PM) [snapback]356858[/snapback][/div][div class=\'quotemain\'][!--quotec--]Admin Panel that couldl insert articles and save them into a MySQL DB.
[/quote]

You said it, my friend.
Link to comment
https://forums.phpfreaks.com/topic/5395-news-adder/#findComment-19520
Share on other sites

[!--quoteo(post=359099:date=Mar 27 2006, 06:54 PM:name=Eddyon)--][div class=\'quotetop\']QUOTE(Eddyon @ Mar 27 2006, 06:54 PM) [snapback]359099[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What are you lost on exactly? Submitting information to the database?
[/quote]
Yeah, and how I should grab the information; I'm new to the MySQL DBs.
BTW, when I have a index.php file, then my web site will give me a "Page not found error," but it will work when I change it to index.htm.
Link to comment
https://forums.phpfreaks.com/topic/5395-news-adder/#findComment-21410
Share on other sites

Well first you must make a table in your MySQL database called news with the following fields:[list][*]id (auto increment)[*]headline[*]article[/list]Next you need to create a form to input the news into, say you have 2 fields, one called 'headline' and another called 'article'. Just for the sake of explaining we can say this file is called addnews.php, and you need to put the form action to post to insertnews.php.

On insertnews.php you first need to connect to the database (if you dont know how click [a href=\"http://www.phpfreaks.com/quickcode/Connect-to-MySQL-Server/29.php?higlight=connect+to+database\" target=\"_blank\"]here[/a]), and you then need to fetch the things you posted, so we set the as variables like this...

$headline = $_POST['headline'];

$article = $_POST['article'];

and now we just do a simple database query to insert the information.

mysql_query("INSERT INTO news (headline, article) VALUES ('$headline', '$article')") or die(mysql_error());

-------------------------------------------------

of corse this is a very basic way with no error checking or anything, but I thought best keep it simple whilst you are learning.

Im goin to bed now but will be back on tomorrow, (if someone hasn't already helped you by then) and if you get on ok with what I just said I will explain how you display it.
Link to comment
https://forums.phpfreaks.com/topic/5395-news-adder/#findComment-21414
Share on other sites

You'll need to make a form which has fields for the data you want to insert. eg

[code]
<form name="news" action="script.php" method="post">
<input type="text" name="headline">
<textarea name="newsbody"></textarea>
<input type="submit" name="submit" value="Submit">
</form>
[/code]

Then you have a script (eg script.php) which you have pointed your form at which accepts the data and inserts it into your database.

[code]
if(isset($_POST['submit'])
{
$headline = $_POST['headline'];
$body = $_POST['newsbody'];

$linkid = mysql_connect('dbhost', 'dbusername', 'dbpassword');
mysql_select_db('dbname', $linkid)
$query = "insert into news_table (headline, body) values ('$headline', '$body')";
$result = mysql_query($query, $linkid);
}
[/code]

This is very basic without any error handling and such but should get you started.

Lol...dammit Eddyon beat me by a whole minute (or 4).
Link to comment
https://forums.phpfreaks.com/topic/5395-news-adder/#findComment-21415
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.