Jump to content

Recommended Posts

Hello,

 

I am have some HTML information that has been submitted to a database.

I would like it to display properly after selecting it.

Can someone tell me how this can be done?

What I've tried so far hasn't worked.

Is there a way to specify that it is HTML code?

If so when to do so? When its being submitted to the database?

When its being selected?

I don't know how to do this. ???

Any help will be greatly appreciated on this one.

Link to comment
https://forums.phpfreaks.com/topic/143355-solved-display-html/
Share on other sites

If this HTML is not shown properly, most likely the tags were stripped or the <> were replaced with their < > counterparts.  I'm assuming you're retrieving the code from the database and then echo it to the screen.  Could you copy/paste the echoed code here (and copy it from the "view source code" screen in your browser so we can see all special characters)?

Link to comment
https://forums.phpfreaks.com/topic/143355-solved-display-html/#findComment-751868
Share on other sites

OK I didn't notice this earlier but apparently its not even being submitted to the database.

 

<?php 

function check_input($data, $problem='')
{
    $data = mysql_real_escape_string(trim(strip_tags(htmlspecialchars($data))));
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}

function show_error($myError) {
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
if ( isset($_POST['submit']) ) {

require_once('Load.php');

$connect = mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($database);

$country = check_input($_POST['country'], "Please choose a country.");
$compname = check_input($_POST['companyname'], "Please enter your company's name.");
$email = htmlspecialchars($_POST['email']);

if (! preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email) ) {
	show_error('E-mail address not valid.');
}

$subject = check_input($_POST['subject'], "Please enter a subject.");

$message = mysql_real_escape_string($_POST['message'], "Please enter your advertisement.");

   $ip = $_SERVER['REMOTE_ADDR'];

   $insert = mysql_query("INSERT INTO $table (col_1, col_2, col_3, col_4, col_5, submission_date, ip_address) VALUES ('$country', '$compname', '$email', '$subject', '$message', ".time().", '$ip')");
}
header('Location: ../advertThanks.php');

exit();

?>

 

Everything but the $message shows up in the database. Could mysql_real_escape_string() be interfering somehow?

 

Link to comment
https://forums.phpfreaks.com/topic/143355-solved-display-html/#findComment-751874
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.