Jump to content

edit news script


velocite

Recommended Posts

Hi again

 

I have two problems:

1. How can i set the location so its a folder below

2. Once executed the page displays an empty screen

 

<?php
//Start session
session_start();
//Setting variable for the input values
$title_input = $_POST['title'];
$body_input = $_POST['bodytext'];
$id = $_POST['id'];
$docroot = $_SERVER['DOCUMENT_ROOT'];

//Including neccessary files to connect to database
    include( '../connect.php');
    include( '../config/config.php');
    
    if (!isset($_POST['title']))
    {
    	header('Location: ' . $docroot . '/test/test4.php');
	$_SESSION['edit_msg'] = '<font color=red>Please fill in the fields</font>';
    }
    if (!isset($_POST['bodytext']))
    {
    	header('Location: ' . $docroot . '/test/test4.php');
	$_SESSION['edit_msg'] = '<font color=red>Please fill in the fields</font>';
    }
    
    //Selecting the Database
mysql_select_db('mycms', $dbconnect);
//Add the inputted content into the database
//"UPDATE example SET age='22' WHERE age='21'"
mysql_query
(
$edittitle = "UPDATE news SET news_title='$title_input' WHERE news_id='$id'"
) or die("MySQL Error:\nMySQL Returned: ".mysql_error());

mysql_query
(
$editbody = "UPDATE news SET news_body='$body_input' WHERE news_id='$id'"
)or die("MySQL Error:\nMySQL Returned: ".mysql_error());

//If statement about displaying error message
if (!$edittitle || !$editbody)
{
	//If unsuccessful, force cancel the operation and display error message
	$_SESSION['edit_msg'] = die('Adding the news failed ' . mysql_error());
	header('Location: ' . $docroot . '/test/test4.php');
}
else
{
	$_SESSION['edit_msg'] = '<font color=green>Adding the news was successful</font><br /><br />';
	header('Location: ' . $docroot . '/test/test4.php');
}


?>

Please help :)

Link to comment
https://forums.phpfreaks.com/topic/101177-edit-news-script/
Share on other sites

1: What location?

2: You don't seem to be outputting anything.

 

1. folder/script

 

the bold is where the script is located and the location should be a page called 'test4.php' in the previous folder called 'folder'

 

2. the output is meant to be in the form of a session message.

 

3. As an additional question, how the heck do you stop a

<?php echo $_SESSION['session_name']; ?>

being display before its actually set.

Link to comment
https://forums.phpfreaks.com/topic/101177-edit-news-script/#findComment-517540
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.