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
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.