<html>
<head><title>Write a New Article</title></head>

<body>
<?php

session_start();


$connect=mysql_connect("localhost", "worldofp_mussy", "mustafa");

mysql_select_db("worldofp_blog1")
      or die(mysql_error());
	  
	  
  $get="SELECT user_id, user_name 
       FROM user 
	   WHERE user_name = '" . $_SESSION['username'] . "'
        ORDER BY user_id";	   
	   
	  	   
	   $results=mysql_query($get)
	     or die(mysql_error());



		 
$row=mysql_fetch_array($results);

 



	$insert="INSERT INTO article( article_name, article_content, 
          user) 
		 [B]VALUES 
		 ( '<h4>" . $_POST['articlename'] .  "</h4>',
		  '<pre>". $_POST['articlecontent'] ."</pre>',
		  '" . $row['user_id'] . "')";[/B]
		  
$results=mysql_query($insert)
       or die(mysql_error());

echo "Congratulations you have successfully entered the article.";
echo "Please click the following link to continue: <br />";
echo "<a href='index.php?log=1' title='Home Page'>continue</a>";

		
		


?>

</body>
</html>

hey guys, i have come to a dead end now. when i display the article the content exceeds the width of the div element. how do i tell the form to produce a new line when ever the the user goes on a new line in the text box form?

i have bolded the part where i am telling the program to produce the article content in a pre code.

an example is in the link

http://www.worldofpakistan.net/blog1/displayart.php?art=1&&log=0

the width of the div should be 500 px, and the corners are supposed to be rounded.

you shouldn't need to. HTML will take care of wrapping text.

whoops, i just looked at the page you linked to. get rid of the <pre> tags...if you the content to appear just as it was entered, you'll need to replace the CRLFs (\r\n) with <br/>s.
...I think

The function is called nl2br That will turn all newlines into HTML linebreaks.

Example:

$Input = "Testing
This is on a new line";
echo nl2br($Input);

Output

Testing<br />
This is on a new line

its notworking. i even have removed the <pre></pre> tags. if the user does not press enter every line then this problem happens.

Don't format their input when they enter it. Format it on output. And since you aren't showing the html/css of where it's getting displayed I can't help you fix that part.

this is the file that prints the output.
do i have to do anything to the form because it is just sending all the data as in one line.
i have removed the formating from the input.

<?php

session_start();
$_SESSION['authuser']=$_SESSION['authuser1'];
?>

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head><title>MN Tech Solutions Blog Software</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keyword" content="" />
<meta name="description" content=" " />
<meta http-equiv="content-language" content="en" />


<script type="text/javascript" src="nifty.js"></script> 

<!--Software House: MN Tech Solutions-->
<!--Designer/Programmer: Mustafa Neguib-->
<!--Date Project Started: 17th June 2008-->

<?php
include 'browsercheck.php';
?>


<style type="text/css">
<!--



-->
</style>


</head>

<body>

<div id="div1">
<script type="text/javascript">
window.onload=function(){
if(!NiftyCheck())
    return;
Rounded("div#first","#EFF6F9","#9BD1FA");
Rounded("div#second","#EFF6F9","#9BD1FA"); 
Rounded("div#third","#EFF6F9","#9BD1FA"); 
}
</script> 

<div id="div2">

<div id="div8">
<img src="logo.jpg" title="Banner" alt="Banner" />
</div>

</div>

<div id="div3">

<div id="main">
<?php


if($_SESSION['authuser']==0)
{


echo "<ul>";
echo "<li><a href='index.php' title='Home Page'>Home Page</a></li>";
echo "<li><a href='show.php' title='Read an Article'>Read an Article</a></li>";
echo "<li><a href='register.php' title='Register'>Register</a></li>";
echo "<li><a href='login.php' title='Login'>Login</a></li>";
echo "<li><a href='sitemap.php' title='Site Map'>Site Map</a></li>";
echo "</ul>";
 }

else 
{
echo "<ul>";
echo "<li><a href='index.php' title='Home Page'>Home Page</a></li>";
echo "<li><a href='show.php' title='Read an Article'>Read an Article</a></li>";
echo "<li><a href='controlpanel.php' title='User Control Panel'>User Control Panel</a></li>";
echo "<li><a href='writearticle.php' title='Write a New Article'>Write a New Article</a></li>";
echo "<li><a href='logout.php' title='Log Out'>Log Out</a></li>";
echo "</ul>";
}
?>

</div>

</div>


<div id="div4">
<div id="first">
<?php

//connect to the database

$create=mysql_query("CREATE DATABASE IF NOT EXISTS worldofp_blog1")
                      or die(mysql_error());
					  
mysql_select_db("worldofp_blog1")
  or die(mysql_error());


$getuser="SELECT user_id, user_name, user
         FROM user
		 LEFT JOIN article
		 ON user=user_id
		 WHERE article_id= '" . $_REQUEST['art'] . "'	
		 ORDER BY user_id;";
		 
		 $results=mysql_query($getuser)
		          or die(mysql_error());
				  
				  
				  
				  $row=mysql_fetch_array($results);
				  
			

$getarticle="SELECT article_name, article_id,article_content
            FROM article
            WHERE  article_id= '" . $_REQUEST['art'] . "'	
			ORDER BY article_id";

$result=mysql_query($getarticle)
    or die(mysql_error());


$rows=mysql_fetch_array($result);


echo "Subject: " . $rows['article_name'];

echo "User:  ";
echo $row['user_name'] ."<br />";

echo "Article Content: ";
echo  nl2br(htmlspecialchars($rows['article_content']));

  
?>
</div>
</div>

<div id="div7">

<?php include'copyright.html';?>

</div>

</div>

</body>
</html>

If nl2br isn't working for you the wordwrap function might

at last the word wrap worked.

thanks to all who helped.

Yes I do have one. Please pm to get the bulk coupon.
Anybody interested in buying itechbids v7.0 @ 10% discount? Please use
my reseller coupon: RES3215.

Don't you think you have spammed enough for the day ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.