Press Enter not taking in textbox

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
I have created a form which have a textbox to take the comments.

All the data send to database which is in PHP, but Anyone Press enter in that or change the line showing perfectly there to the user but....not showing in the database....showing just simple one line with all the text. Please tell me what i have to do....so that keyboard enter will be taken.

Anything can be done in the HTML form page.
 
Joined
Jan 4, 2006
Messages
112
Do a view-source on the page that shows all the text in one line. If the html is broken up as it should be, then the data is entering the database correctly.

It'll look like this:
HTML:
<p id="comments">
These are the comments that I
left on your website with hard
breaks in between the lines.
</p>
but will be displayed in one line.

If this is the case, you can either <pre>format the text or you can try to parse it manually i.e. in php, every time there is a newline, output a <br /> tag.

If it is not entering the database correctly, you need to check your submit page to make sure it's not filtering line breaks and whitespace.

One more possibility is that the text is wrapping when it reaches the end of the textarea and there is not actually a hard break on the line. There's nothing you can do about this unless you output the text into a different textarea of the same size (# of columns). I guess technically you could parse out all of the strings and insert <br /> tags every X many columns, but that would be a pain in the butt!
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
Well..I just know that Wrap of the textbox is set to default but now i have changed to "Physical" but still data send to me in one line.

And Submit page not filtering the linebreaks and whitebreaks.

And how to view the page source because when data submitted then not shown on the page, just show a confirmation.
 
Joined
Jan 4, 2006
Messages
112
It will always be stored in the database as one line. It will have the correct whitespace characters in it, though.

How are you viewing the database? Are you looking directly in some sort of database management software OR are you using PHP to extract the data from the database and then place it on a webpage? I was under the impression that you were doing the 2nd one, but now it sounds like you're doing the 1st one. You won't have any control over how something like query analyzer shows you your data.
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
If I see the data in phpMyadmin then it shows in different lines...(properly)

But when i allowed to show that data on a page for general public then it shows in a one line.

And also when i see the data in my admin panel page then it also showing in the one line.


You can think like that....someone send me a movie review to post on a website...but without reviewing by me or not allowed by me not posted on a website. Right now correctly showing only in the PHPmyadmin.
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
I am posting a php code which process the form...

Code:
<?php
require_once('connect.php');

	if( $HTTP_POST_VARS['jobname'] && $HTTP_POST_VARS['country'] && $HTTP_POST_VARS['jobcity'] && $HTTP_POST_VARS['jobduration'] && $HTTP_POST_VARS['numberjobs'] && $HTTP_POST_VARS['jobdescription'] && $HTTP_POST_VARS['companyname'] && $HTTP_POST_VARS['yourname'] && $HTTP_POST_VARS['contactemail'] && $HTTP_POST_VARS['phone'] && $HTTP_POST_VARS['designation'] )
	{
	
	$jobname=$HTTP_POST_VARS['jobname'];
	$country=$HTTP_POST_VARS['country'];
	$jobcity=$HTTP_POST_VARS['jobcity'];
	
	$startdate=$HTTP_POST_VARS['startdate'];
	if(strlen($startdate)==6)
		$startdate=substr($startdate,4,2).'-'.substr($startdate,2,1).'-'.substr($startdate,0,1);
	else
	{
	$y=substr($startdate,6,4);
		if(strlen(y)==2)
		$y='20'.$y;
	$m=substr($startdate,3,2);
		if(strlen($m)==1)
		$m='0'.$m;
	$d=substr($startdate,0,2);
		if(strlen($d)==1)
		$d='0'.$d;
	$startdate=$y.'-'.$m.'-'.$d;
	}
	
	$jobtype=$HTTP_POST_VARS['jobtype'];
	$jobduration=$HTTP_POST_VARS['jobduration'];
	$salary=$HTTP_POST_VARS['salary'];
	$numberjobs=$HTTP_POST_VARS['numberjobs'];
	$jobdescription=$HTTP_POST_VARS['jobdescription'];
	$jobrequirements=$HTTP_POST_VARS['jobrequirements'];
	$companyname=$HTTP_POST_VARS['companyname'];
	$yourname=$HTTP_POST_VARS['yourname'];
	$contactemail=$HTTP_POST_VARS['contactemail'];
	$phone=$HTTP_POST_VARS['phone'];
	$designation=$HTTP_POST_VARS['designation'];
	$address=$HTTP_POST_VARS['address'];
	$companydescription=$HTTP_POST_VARS['companydescription'];
	$website=$HTTP_POST_VARS['website'];
	
	$query="insert into jobs (jobname,jobcountry,jobcity,startdate,jobtype,jobduration,salary,numberofjobs,jobdescription,jobrequirements,companyname,yourname,email,phone,designation,companyaddress,companydescription,website,status) values('$jobname','$country','$jobcity','$startdate','$jobtype','$jobduration','$salary','$numberjobs','$jobdescription','$jobrequirements','$companyname','$yourname','$contactemail','$phone','$designation','$address','$companydescription','$website','pending')";
	[email protected]_query( $query );
		if($result)
		{
		echo '<br><font class="jobposted" align="left"><b>Your job is posted...</b><br><hr><br>';		
		[email protected]_query( "select jobid from jobs where companyname='".$companyname."' and jobname='".$jobname."'" );
			if($result)
			{
			$row=mysql_fetch_array($result);
			echo '<br>Plz note down the following information for future reference...';
			echo '<br>Your job id is: '.$row[0];
			}
		echo '</font><br><br><br><br><a href="postajob.html">Click here to post another job...</a>';
		}
		else
		{
		echo 'Data can not be posted due to  : '.mysql_error();
		}
	}

mysql_close($cn);
?>
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
I have not done any trimming...that is the php code which processing the form. I just copy and paste all the code.
 
Joined
Dec 17, 2004
Messages
606
You posted the code to submit the information. Could you post the code that gets and displays the information?
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
Well, I m not fully sure....but think you are looking for this code, display detail of the information.

Code:
<?php
$width=200;
$titlealign="right";

require_once('connect.php');
$jobid=$HTTP_GET_VARS['jobid'];

$query="select *,DATE_FORMAT(dateposted,'%d-%m-%Y'),DATE_FORMAT(startdate,'%d-%m-%Y')   from jobs where status='allowed' and jobid=". $jobid;
//$query='select * from jobs where status="allowed" and jobid='. $jobid;
[email protected]_query( $query );


	if($result)
	{
	$row=mysql_fetch_array($result);
	
	echo '<br><div class="jobname">'.$row[1].'</div>';
	echo '<div class="cname">'.$row[11].'</div><br>';	
	
	
	echo '<table cellpadding="5">';	

//########################################################################	
	if(!empty($row[21]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Date of posting:</td><td class='data' valign='top'>".$row[21]."</td></tr>";
	
	if(!empty($row[2]) || !empty($row[3]) )
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Location:</td><td class='data' valign='top'>".$row[3].", ".$row[2]."</td></tr>";	
	
	if(!empty($row[9]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Job Description:</td><td class='data' valign='top' align='justify'>".$row[9]."</td></tr>";	
	
	if(!empty($row[10]))
		echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Job Requirements:</td><td class='data' valign='top' align='justify'>".$row[10]."</td></tr>";	

//########################################################################
	if(!empty($row[22]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Start Date:</td><td class='data' valign='top'>".$row[22]."</td></tr>";	

	if(!empty($row[5]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Job Type: </td><td class='data' valign='top'>".$row[5]."</td></tr>";	

	if(!empty($row[6]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Job Duration:</td><td class='data' valign='top'>".$row[6]."</td></tr>";	

	if(!empty($row[7]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Salary:</td><td class='data' valign='top'>".$row[7]."</td></tr>";	

	if(!empty($row[8]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Number of Jobs:</td><td class='data' valign='top'>".$row[8]."</td></tr>";	


	echo '</table>';	
	echo '<hr width="50%">';
	echo '<table cellpadding="5">';	


	if(!empty($row[11]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Company:</td><td class='data' valign='top'>".$row[11]."</td></tr>";	

	if(!empty($row[17]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Company Description:</td><td class='data' valign='top' align='justify'>".$row[17]."</td></tr>";	


	if(!empty($row[16]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Company Address:</td><td class='data' valign='top'>".$row[16]."</td></tr>";	

	if(!empty($row[13]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>E-mail:</td><td class='data' valign='top'><a href='mailto:".$row[13]."'>".$row[13]."</a></td></tr>";	

	if(!empty($row[18]))
	echo "<tr><td class='title' width='".$width."px' align='".$titlealign."' valign='top'>Website:</td><td class='data' valign='top'><a href='".$row[18]."' target='_blank'>".$row[18]."</a></td></tr>";	
	
	echo '</table>';
	}
	else
	{
	echo 'Information cant be displayed due to system error, We apologize for any inconvenience...'.mysql_error();
	}


mysql_close($cn);
?>
 

ashras99

Thread Starter
Joined
Jul 13, 2002
Messages
1,044
In all 4 textboxes (jobdescription, jobrequirements, address, companydescription)

So that data shown same as entered not in the one line.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top