Jump to content

Recommended Posts

It's been a while since I've done any PHP, so I'm making a simple guestbook script just to get back into the swing of it. I've managed to get it working just fine except for one thing.

 

When you type some text in the text field that has multiple lines and submit it, it will produce the entry all on one line.

 

For example this entry:

 

Testing 123

 

Testing 123

 

Testing 123

 

Will appear as:

 

Testing 123 Testing 123 Testing 123

 

I don't even know what the process is called to solve this. I can do it by entering HTML into the text box but that's something I'd rather avoid.

 

Any help on this would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/142350-quick-form-question/
Share on other sites

Oh sorry forgot about the code

 

<?php

include("config.php");

  if($submit)

  {//begin of if($submit).

      $title = mysql_real_escape_string($_POST['title']);
      $user = mysql_real_escape_string($_POST['user']);
      $text2 = mysql_real_escape_string($_POST['text2']);

	//run query

         $result = mysql_query("INSERT INTO scnews (title, dtime, user, text2)

                       VALUES ('$title',NOW(),'$user','$text2')",$connect);

          //print success message.

          echo "<b>Thank you! entry added successfully!<br>";

          echo "<meta http-equiv=Refresh content=0;url=index.php>";

  }//end of if($submit).


else

  {//begin of else

      ?>
      <br>
      <h3>Add news article</h3>
      <form method="post" action="<?php echo $PHP_SELF ?>">
      Title: <input name="title" size="40" maxlength="255">
      <br>
      Name: <input name="user" size="40" maxlength="255">
      <br>
      Comments: <textarea name="text2" rows="7" cols="30"></textarea>
      <br>
      <input type="submit" name="submit" value="Sign Guestbook">
      </form>
      <?

  }//end of else

?>

Link to comment
https://forums.phpfreaks.com/topic/142350-quick-form-question/#findComment-745870
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.