you need to remove the " incoming.php " part.
The variablecall_typeshould hold either the word "incoming" or "outgoing" at this point.
PHP Code:header("Location: http://localhost/OJT/mae_ann/".$call_type.".php");
Printable View
you need to remove the " incoming.php " part.
The variablecall_typeshould hold either the word "incoming" or "outgoing" at this point.
PHP Code:header("Location: http://localhost/OJT/mae_ann/".$call_type.".php");
I tried the code you suggested:
And the output is still it did not go to incoming.php when I choose incoming .PHP Code:<?php
include ("config.php");
if (isset($_POST['call_type'])) {
// escape the value
$call_type = mysql_real_escape_string($_POST['call_type']);
// query the database
$result = mysql_query("SELECT `call_type` FROM `tbl_calltype` WHERE `call_type` = '{$call_type}' ");
// if there's one row in the result, then there was a match.
if(mysql_num_rows($result) === 1){
// send the header()
//here I got confused because i dont know what location should i put is it incoming.php or outgoing.php, but when I tried this code nothig was happened.
// at this point, since we've gotten a match from the database,
// we know that the variable 'call_type' holds a value of either "incoming" or "outgoing",
// so we use the variable instead of hard-coding the filename.
header("Location: http://localhost/OJT/mae_ann/".$call_type.".php");
}
//else{ header("Location: http://localhost/OJT/mae_ann/outgoing.php"); }
}
?>
<html>
<body>
<form id="form1" name="form1" method="post" action="">
<select name="call_type" onchange="return handleEnter(this, event)">
<option value="Select Call Type">Select Call Type</option>
<option value="Incoming" <?php if($_POST['call_type'] == 'Incoming') echo "selected='selected'"; ?>>Incoming</option>
<option value="Outgoing" <?php if($_POST['call_type'] == 'Outgoing') echo "selected='selected'"; ?>>Outgoing</option>
</select>
<input type="submit" name = "Submit" value="Submit">
</form>
</body>
</html>
:confused:
Thank you
hmm... where is it going? do you get a 404? do you get anything?
does this work?
?PHP Code:header("Location: http://localhost/OJT/mae_ann/incoming.php");
try this
so we can see if the value is getting passed on correctly.PHP Code:print call_type;
try this and let me know what it tells you.
PHP Code:<?php
include ("config.php");
if(isset($_POST['call_type'])){
$call_type = mysql_real_escape_string($_POST['call_type']);
$result = mysql_query("SELECT `call_type` FROM `tbl_calltype` WHERE `call_type` = '{$call_type}' ");
if(!$result){ print 'the query did not execute properly: '.mysql_error().'<br>'; }
// if the line below doesn't work, try commenting it out and using the commented line instead
if(mysql_num_rows($result) === 1){
// if(mysql_num_rows($result) > 0){
header("Location: http://localhost/OJT/mae_ann/".$call_type.".php");
}else{
var_dump($call_type);
}
}else{ print '$_POST[call_type] is not set<br>'; }
?>
<html>
<head>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<select name="call_type" onchange="return handleEnter(this, event)">
<option value="Select Call Type">Select Call Type</option>
<option value="incoming">Incoming</option>
<option value="outgoing">Outgoing</option>
</select>
<input type="submit" name = "Submit" value="Submit">
</form>
</body>
</html>
glad it worked! just FYI, the following lines are solely for testing purposes and can/should be commented or removed:
PHP Code:if(!$result){ print 'the query did not execute properly: '.mysql_error().'<br>'; }
PHP Code:else{
var_dump($call_type);
}
PHP Code:// if the line below doesn't work, try commenting it out and using the commented line instead
// if(mysql_num_rows($result) > 0){
PHP Code:else{ print '$_POST[call_type] is not set<br>'; }