You are here: how to open a php page automatically « PHP Programming Language « IT news, forums, messages
how to open a php page automatically

Posted by Stephen V on 04/02/06 15:43

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($stmt)){

oci_free_statement($stmt);
print "add_task.php?request_name=$req_name";
//header("http://127.0.0.1/add_task.php?request_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 "$addrequest <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_id = $_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_expected_date'];

$req_comment = $_POST['request_comment'];

$c1=oci_connect("stephane","Stef1975",$bdtest05);

$query="insert into requests (
request_name, request_date, request_client_id, request_request_type_id,
request_brand_id, request_wished_delivery_date, request_comment)
values
('$req_name',to_date('$req_date','DD.MM.YYYY'),$req_client_id,$req_req_type_id,
$req_brand_id,to_date('$req_exp_date','DD.MM.YYYY'),'$req_comment')";

$stmt=oci_parse($c1,$query);



Print "$stmt <BR>";
Print "$query <BR>";

If (oci_execute($stmt)){

oci_free_statement($stmt);
print "add_task.php?request_name=$req_name";
//header("http://127.0.0.1/add_task.php?request_name=$req_name");
};
// gestion du ELse: erreur dans l'insertion en BdD

}

?>
<center><h1>Add request</h1></p></center>
<hr>

<p align="center">
&nbsp;

<form method="POST" name="requestform" action="add_request.php">
<table border="1" width="50%">
<tr>
<td align="left" width="50%" height="25">
<p align="left">Request Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><input type="text" size="40"
name="request_name">&nbsp<b>*</b>&nbsp</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Request Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><input type="text" size="20"
name="request_date">&nbsp<b>*</b>&nbsp;&nbsp;
<a
href="javascript:show_calendar('requestform.request_date',null,null,'DD.MM.YYYY');"
onMouseOver="window.status='Date Picker'; overlib('Click here to choose a
date from a one month pop-up calendar.'); return true;"
onMouseOut="window.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">Client Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_client_name" size="1">
<option>Client Name</option>
<?php

//connection to database

$c1=oci_connect("stephane","Stef1975",$bdtest05);

$query="select client_id, client_firstname||' '||client_lastname as
client_fullname from clients";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo"<option value=$row[0]>$row[1]</option>";
}

oci_free_statement($stmt);
?>

</select>&nbsp<b>*</b></p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Request Type</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_type" size="1">
<option>Request Type</option>

<?php

$query="select request_type_id, request_type_name from request_types";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo"<option value=$row[0]>$row[1]</option>";
}

oci_free_statement($stmt);

?>

</select>&nbsp<b>*</b>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Brand Name</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left">
<select name="request_brand_name" size="1">
<option>Brand Name</option>

<?php

$query="select brand_id, brand_name from brands";

$stmt=oci_parse($c1,$query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt,OCI_NUM))
{
echo"<option value=$row[0]>$row[1]</option>";
}

oci_free_statement($stmt);

//close connection to database

oci_close($c1);
?>

</select>
</p>
</td>
</tr>
<tr>
<td align="left" width="50%" height="25">
<p align="left">Expected Delivery Date</p>
</td>
<td align="left" width="50%" height="25" colspan="2">
<p align="left"><input type="text" size="20"
name="request_expected_date">&nbsp<b>*</b>&nbsp;&nbsp;
<a
href="javascript:show_calendar('requestform.request_expected_date',null,null,'DD.MM.YYYY');"
onMouseOver="window.status='Date Picker'; overlib('Click here to choose a
date from a full year pop-up calendar.'); return true;"
onMouseOut="window.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">Comment on Request</p>
</td>
<td align="left" width="50%" height="25" colspan="2"><textarea
name="request_comment" 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"><input type="submit" name="addrequest" value="add
request">
</p>
</td>
<td align="left" width="25%" height="25">
<input type="reset" name="resetButton" value="Reset">
</td>
</tr>
</table>
</form>
<p align="left"></p>
<hr>

<div id="overDiv" style="position:absolute; visibility:hidden;
z-index:1000;"></div>


<p align="center"><a href="index.php">[Home]</a></p>


</form>
</body>

</html>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация