Can anyone help me out with this problem.
I would like to redirect/ go to another php page when my SQL insertion is
done and also send a variable at the same time.
the idea is, to come on my page for the first time and not doing anything,
then I fill up my form and insert the data (with the button "add request"
and when the oci_execute is done go to another page.
all I need to know is how to go to another page automatically.. . and alos
send a variable at the same time I tried something but it doesn't work...
//it's here what I tried to do:
If (oci_execute($s tmt)){
oci_free_statem ent($stmt);
print "add_task.php?r equest_name=$re q_name";
//header("http://127.0.0.1/add_task.php?re quest_name=$req _name"); // it's
here I need a solution.
};
// thanks for your help
}
=============== =============== =============== =============== =
//here is my whole php page.
<?php
// variable name of submit button of request form
$addrequest = $_POST['addrequest'];
print "$addreques t <BR>";
//test if something is submited in the form if this is the case then insert
data in DB
if ($addrequest!=' ') {
$req_name = $_POST['request_name'];
$req_date = $_POST['request_date'];
$req_client_id = $_POST['request_client _name'];
$req_req_type_i d = $_POST['request_type'];
$req_brand_id = $_POST['request_brand_ name'];
if ($req_brand_id= ='Brand Name') $req_brand_id=' NULL';
$req_exp_date = $_POST['request_expect ed_date'];
$req_comment = $_POST['request_commen t'];
$c1=oci_connect ("stephane","St ef1975",$bdtest 05);
$query="insert into requests (
request_name, request_date, request_client_ id, request_request _type_id,
request_brand_i d, request_wished_ delivery_date, request_comment )
values
('$req_name',to _date('$req_dat e','DD.MM.YYYY' ),$req_client_i d,$req_req_type _id,
$req_brand_id,t o_date('$req_ex p_date','DD.MM. YYYY'),'$req_co mment')";
$stmt=oci_parse ($c1,$query);
Print "$stmt <BR>";
Print "$query <BR>";
If (oci_execute($s tmt)){
oci_free_statem ent($stmt);
print "add_task.php?r equest_name=$re q_name";
//header("http://127.0.0.1/add_task.php?re quest_name=$req _name");
};
// gestion du ELse: erreur dans l'insertion en BdD
}
?>
<center><h1>A dd request</h1></p></center>
<hr>
<p align="center">
<form method="POST" name="requestfo rm" action="add_req uest.php">
<table border="1" width="50%">
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="40"
name="request_n ame"> <b>* </b> </p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="20"
name="request_d ate"> <b>* </b>
<a
href="javascrip t:show_calendar ('requestform.r equest_date',nu ll,null,'DD.MM. YYYY');"
onMouseOver="wi ndow.status='Da te Picker'; overlib('Click here to choose a
date from a one month pop-up calendar.'); return true;"
onMouseOut="win dow.status=''; nd(); return true;"><img
src="show-calendar.gif" width=24 height=22 border=0></a></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Cl ient Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_c lient_name" size="1">
<option>Clien t Name</option>
<?php
//connection to database
$c1=oci_connect ("stephane","St ef1975",$bdtest 05);
$query="select client_id, client_firstnam e||' '||client_lastn ame as
client_fullname from clients";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
?>
</select> <b> *</b></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Type</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_t ype" size="1">
<option>Reque st Type</option>
<?php
$query="select request_type_id , request_type_na me from request_types";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
?>
</select> <b> *</b>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Br and Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_b rand_name" size="1">
<option>Brand Name</option>
<?php
$query="select brand_id, brand_name from brands";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
//close connection to database
oci_close($c1);
?>
</select>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Ex pected Delivery Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="20"
name="request_e xpected_date">& nbsp<b>*</b>
<a
href="javascrip t:show_calendar ('requestform.r equest_expected _date',null,nul l,'DD.MM.YYYY') ;"
onMouseOver="wi ndow.status='Da te Picker'; overlib('Click here to choose a
date from a full year pop-up calendar.'); return true;"
onMouseOut="win dow.status=''; nd(); return true;"><img
src="show-calendar.gif" width=24 height=22 border=0></a></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Co mment on Request</p>
</td>
<td align="left" width="50%" height="25" colspan="2"><te xtarea
name="request_c omment" cols="30" rows="4"></textarea><p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left"></td>
<td align="left" width="25%" height="25">
<p align="left"><i nput type="submit" name="addreques t" value="add
request">
</p>
</td>
<td align="left" width="25%" height="25">
<input type="reset" name="resetButt on" value="Reset">
</td>
</tr>
</table>
</form>
<p align="left"></p>
<hr>
<div id="overDiv" style="position :absolute; visibility:hidd en;
z-index:1000;"></div>
<p align="center"> <a href="index.php ">[Home]</a></p>
</form>
</body>
</html>
I would like to redirect/ go to another php page when my SQL insertion is
done and also send a variable at the same time.
the idea is, to come on my page for the first time and not doing anything,
then I fill up my form and insert the data (with the button "add request"
and when the oci_execute is done go to another page.
all I need to know is how to go to another page automatically.. . and alos
send a variable at the same time I tried something but it doesn't work...
//it's here what I tried to do:
If (oci_execute($s tmt)){
oci_free_statem ent($stmt);
print "add_task.php?r equest_name=$re q_name";
//header("http://127.0.0.1/add_task.php?re quest_name=$req _name"); // it's
here I need a solution.
};
// thanks for your help
}
=============== =============== =============== =============== =
//here is my whole php page.
<?php
// variable name of submit button of request form
$addrequest = $_POST['addrequest'];
print "$addreques t <BR>";
//test if something is submited in the form if this is the case then insert
data in DB
if ($addrequest!=' ') {
$req_name = $_POST['request_name'];
$req_date = $_POST['request_date'];
$req_client_id = $_POST['request_client _name'];
$req_req_type_i d = $_POST['request_type'];
$req_brand_id = $_POST['request_brand_ name'];
if ($req_brand_id= ='Brand Name') $req_brand_id=' NULL';
$req_exp_date = $_POST['request_expect ed_date'];
$req_comment = $_POST['request_commen t'];
$c1=oci_connect ("stephane","St ef1975",$bdtest 05);
$query="insert into requests (
request_name, request_date, request_client_ id, request_request _type_id,
request_brand_i d, request_wished_ delivery_date, request_comment )
values
('$req_name',to _date('$req_dat e','DD.MM.YYYY' ),$req_client_i d,$req_req_type _id,
$req_brand_id,t o_date('$req_ex p_date','DD.MM. YYYY'),'$req_co mment')";
$stmt=oci_parse ($c1,$query);
Print "$stmt <BR>";
Print "$query <BR>";
If (oci_execute($s tmt)){
oci_free_statem ent($stmt);
print "add_task.php?r equest_name=$re q_name";
//header("http://127.0.0.1/add_task.php?re quest_name=$req _name");
};
// gestion du ELse: erreur dans l'insertion en BdD
}
?>
<center><h1>A dd request</h1></p></center>
<hr>
<p align="center">
<form method="POST" name="requestfo rm" action="add_req uest.php">
<table border="1" width="50%">
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="40"
name="request_n ame"> <b>* </b> </p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="20"
name="request_d ate"> <b>* </b>
<a
href="javascrip t:show_calendar ('requestform.r equest_date',nu ll,null,'DD.MM. YYYY');"
onMouseOver="wi ndow.status='Da te Picker'; overlib('Click here to choose a
date from a one month pop-up calendar.'); return true;"
onMouseOut="win dow.status=''; nd(); return true;"><img
src="show-calendar.gif" width=24 height=22 border=0></a></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Cl ient Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_c lient_name" size="1">
<option>Clien t Name</option>
<?php
//connection to database
$c1=oci_connect ("stephane","St ef1975",$bdtest 05);
$query="select client_id, client_firstnam e||' '||client_lastn ame as
client_fullname from clients";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
?>
</select> <b> *</b></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Re quest Type</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_t ype" size="1">
<option>Reque st Type</option>
<?php
$query="select request_type_id , request_type_na me from request_types";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
?>
</select> <b> *</b>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Br and Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_b rand_name" size="1">
<option>Brand Name</option>
<?php
$query="select brand_id, brand_name from brands";
$stmt=oci_parse ($c1,$query);
oci_execute($st mt);
while ($row = oci_fetch_array ($stmt,OCI_NUM) )
{
echo"<option value=$row[0]>$row[1]</option>";
}
oci_free_statem ent($stmt);
//close connection to database
oci_close($c1);
?>
</select>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Ex pected Delivery Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><i nput type="text" size="20"
name="request_e xpected_date">& nbsp<b>*</b>
<a
href="javascrip t:show_calendar ('requestform.r equest_expected _date',null,nul l,'DD.MM.YYYY') ;"
onMouseOver="wi ndow.status='Da te Picker'; overlib('Click here to choose a
date from a full year pop-up calendar.'); return true;"
onMouseOut="win dow.status=''; nd(); return true;"><img
src="show-calendar.gif" width=24 height=22 border=0></a></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Co mment on Request</p>
</td>
<td align="left" width="50%" height="25" colspan="2"><te xtarea
name="request_c omment" cols="30" rows="4"></textarea><p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left"></td>
<td align="left" width="25%" height="25">
<p align="left"><i nput type="submit" name="addreques t" value="add
request">
</p>
</td>
<td align="left" width="25%" height="25">
<input type="reset" name="resetButt on" value="Reset">
</td>
</tr>
</table>
</form>
<p align="left"></p>
<hr>
<div id="overDiv" style="position :absolute; visibility:hidd en;
z-index:1000;"></div>
<p align="center"> <a href="index.php ">[Home]</a></p>
</form>
</body>
</html>
Comment