Jump to content

die(); killing whole script *help please*


Hollows

Recommended Posts

Ok, what I want to happen is, if if($_POST['select'] == 'choose'){ is submitted, the script to display an error and not proccess anything after with the die(); message displayed to the user, but it's not showing the message, and infact when if($_POST['select'] is submitted as another array (I'm sorry, is that the correct term?) it still kills the whole script.

 

I've check in my db an nothing is updating the tables so I guess die is working to an degree.

 

I've tried it without the die commands an it works as it should so I know the info does get sent without the die

 

Here is my code so far -

 

<?php
/**************************
database info
****************************/
$host = "***";
$user = "***";
$pass = "***";
$db = "***";
/****************************
define variables
****************************/
$name = $_POST['name'];
$message = $_POST['message'];

mysql_connect($host, $user, $pass) OR die ("Could not connect to the server."); 
mysql_select_db($db) OR die("Could not connect to the database."); // connect to server or die 
?>
<?php
if(isset($_POST['submit']))
{
if($_POST['select'] == 'choose'){ 
    die("please select a shout or request from the drop down");// if no drop down is selected, kill the script and explain why
}

else if($_POST['select'] == 'shouts'){
  // begin shouts
$message = htmlspecialchars($message);
$message = nl2br($message);
$message = mysql_real_escape_string($message);
$name = htmlspecialchars($name);
$name = mysql_real_escape_string($name);
$class = "shout"; // assigns the css class to be used when the results are called
{
mysql_query("INSERT INTO shoutbox (name, message, class) VALUES ('$name', '$message', $class)");
}}
// begin request

?>
<link href="css/vip_sheet.css" rel="stylesheet" type="text/css" />

<div id="shout-container">
<div id="shouts">
<?php
$result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 0,10");
while ($row = mysql_fetch_array($result)) {
?>
<div class="<?php echo $row['class'];  ?>">
<b><?php echo $row['name']; ?></b><br />
<?php echo $row['message']; ?></div>
<?php
}}
?>
</div>
</div>

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/211271-die-killing-whole-script-help-please/
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.