...

View Full Version : Need Help Re-Directing



JasonReynolds
06-22-2010, 06:53 PM
Hey all, I am making a fansite for last chaos and it has a radio on it. I have a request line code sorted out. But if the user presses confirm it does not auto refresh and go back to the form.

Here is the code:

<?php
include ("config.php");
if(!$_POST[request])
{
echo "
<form method='post'>
<p><strong>Name:</strong>
<input name='name' type='text' id='content'><br>
</p>
<p><strong>Reason:</strong>
<select name='type' id='content'>
<option><font color=#Shoutout</option>
<option>Request</option>
<option>Complaint</option>
</select>
<br><br>
<strong>Message:</strong><br>
<textarea name='message' cols='30' id='content' style='height: 100px;'></textarea>
<br>
<br>
<input type='submit' name='request' value='Send' id='content'>
</p>
</form>
";
}

if($_POST[request])
{

$type = $_POST['type'];
$name = $_POST['name'];
$message = $_POST['message'];
if($type == NULL || $name == NULL || $message == NULL)
{
die("All the fields are required. Please make sure you fill them out!");
}
$ip = $_SERVER['REMOTE_ADDR'];
$check = mysql_query("SELECT bannedip FROM `ipbans` WHERE `bannedip` = '$ip'");
$check = mysql_fetch_array($check);

if ($check[bannedip] !== $ip)
{
$ip = $_SERVER['REMOTE_ADDR'];
$message = $_POST['message'];
$type = $_POST['type'];
$name = $_POST['name'];
mysql_query("INSERT INTO `requests` (`id`, `user`, `message`, `type`, `ip`) VALUES (NULL, '$name', '$message', '$type', '$ip');");
echo ("<center>Thankyou for submitting your shoutout/request/complaint,<br> a DJ or admin will view it soon.</center>"); //Thankyou message.
}
else
{
echo ("Your IP matches one of a banned IP. If you are using a proxy, please disable it and try again."); //Banned IP message.
}
}
?>

Any Insight?

johnduarte
06-22-2010, 07:07 PM
From what i understand, you're wanting it to go back to the form after they submit? Why not just switch the order of your code then, and take out the conditional for the form?



<?php
include ("config.php");
if(isset($_POST[request]))
{

$type = $_POST['type'];
$name = $_POST['name'];
$message = $_POST['message'];
if($type == NULL || $name == NULL || $message == NULL)
{
die("All the fields are required. Please make sure you fill them out!");
}
$ip = $_SERVER['REMOTE_ADDR'];
$check = mysql_query("SELECT bannedip FROM `ipbans` WHERE `bannedip` = '$ip'");
$check = mysql_fetch_array($check);

if ($check[bannedip] !== $ip)
{
$ip = $_SERVER['REMOTE_ADDR'];
$message = $_POST['message'];
$type = $_POST['type'];
$name = $_POST['name'];
mysql_query("INSERT INTO `requests` (`id`, `user`, `message`, `type`, `ip`) VALUES (NULL, '$name', '$message', '$type', '$ip');");
echo ("<center>Thankyou for submitting your shoutout/request/complaint,<br> a DJ or admin will view it soon.</center>"); //Thankyou message.
}
else
{
echo ("Your IP matches one of a banned IP. If you are using a proxy, please disable it and try again."); //Banned IP message.
}
}
?>

<form method='post'>
<p><strong>Name:</strong>
<input name='name' type='text' id='content'><br>
</p>
<p><strong>Reason:</strong>
<select name='type' id='content'>
<option><font color=#Shoutout</option>
<option>Request</option>
<option>Complaint</option>
</select>
<br><br>
<strong>Message:</strong><br>
<textarea name='message' cols='30' id='content' style='height: 100px;'></textarea>
<br>
<br>
<input type='submit' name='request' value='Send' id='content'>
</p>
</form>

JasonReynolds
06-22-2010, 07:35 PM
Any idea how to make the message above it fade? When you post it says:
Thankyou for submitting your shoutout/request/complaint,
a DJ or admin will view it soon.

But i need that to fade away

johnduarte
06-22-2010, 07:49 PM
Any idea how to make the message above it fade? When you post it says:
Thankyou for submitting your shoutout/request/complaint,
a DJ or admin will view it soon.

But i need that to fade away

Just a quick and dirty solution, you can use javascript to hide the message.


<?php
include ("config.php");
if(isset($_POST[request]))
{

$type = $_POST['type'];
$name = $_POST['name'];
$message = $_POST['message'];
if($type == NULL || $name == NULL || $message == NULL)
{
die("All the fields are required. Please make sure you fill them out!");
}
$ip = $_SERVER['REMOTE_ADDR'];
$check = mysql_query("SELECT bannedip FROM `ipbans` WHERE `bannedip` = '$ip'");
$check = mysql_fetch_array($check);

if ($check[bannedip] !== $ip)
{
$ip = $_SERVER['REMOTE_ADDR'];
$message = $_POST['message'];
$type = $_POST['type'];
$name = $_POST['name'];
mysql_query("INSERT INTO `requests` (`id`, `user`, `message`, `type`, `ip`) VALUES (NULL, '$name', '$message', '$type', '$ip');");
echo ("<div id=\"hid\" style=\"visibility:visible\"><center>Thankyou for submitting your shoutout/request/complaint,<br> a DJ or admin will view it soon.</center></div>"); //Thankyou message.
$hideDiv = TRUE;
}
else
{
echo ("Your IP matches one of a banned IP. If you are using a proxy, please disable it and try again."); //Banned IP message.
}
}
?>


<form method='post'>
<p><strong>Name:</strong>
<input name='name' type='text' id='content'><br>
</p>
<p><strong>Reason:</strong>
<select name='type' id='content'>
<option><font color=#Shoutout</option>
<option>Request</option>
<option>Complaint</option>
</select>
<br><br>
<strong>Message:</strong><br>
<textarea name='message' cols='30' id='content' style='height: 100px;'></textarea>
<br>
<br>
<input type='submit' name='request' value='Send' id='content'>
</p>
</form>
<?php if($hideDiv){ ?>
<script type="text/javascript">
function hideIt() {
document.getElementById("hid").style.visibility = "hidden";
}
setTimeout("hideIt()", 10000); // after 10 sec
</script>
<?php } ?>


Setting the variable $hideDiv after the message which is now in a div in your php code, then checking later to see if $hideDiv is set, if so javascript will run.

JasonReynolds
06-22-2010, 08:01 PM
Thanks John, Really helped



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum