how to post already posted variables!?!?
Moderator: General Moderators
how to post already posted variables!?!?
<?php
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('db_nik');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=1;
if ($i==1)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Cyan> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
}
?>
How am i gonna be able to give the variables to the selected php scripts?
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('db_nik');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=1;
if ($i==1)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Cyan> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
}
?>
How am i gonna be able to give the variables to the selected php scripts?
You may be able to send a POST header with the header() function, but I'm not sure. I'd check out the HTTP1.1 RFC and the POST Section specifically.
also, this looks like a pretty reasonable solution: POSTing without a form
c.collins
also, this looks like a pretty reasonable solution: POSTing without a form
c.collins
Is there a way that i can redirect a php script usinfg the header command to another php script and then after the other php script finishes to return control tou the next line from the caller script? i want this because i have a code in one script that i use to often that i want to return a value its time like a function but in another php script so that i cant paste this code to evry other php script!
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
If you put the script you want to use often into a function in its own file then you can just include() this file into other scripts and gain access to the function. For what you are trying to do this would probably be the way I would go about it.
Mac
Mac
i also get this from my remote web server when i use htaccess by a header command
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin-uk@lycos-europe.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin-uk@lycos-europe.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
The concept does work - perhaps there's a problem with your implementation.Nik wrote:Well that look s very good idea bu i tried it and it didint work!
Normally you would have a script posting to b script and b script including c script in order to use a function in c.Nik wrote:tha a script posts to b script and i have in c script the include 'b.php'
but it dosent get the varibles that b has
ehay is that?
Mac
My index.php posts to post.php ehich is the following
<?php
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('nikosgr_uk_db');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=0;
if ($i==0)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Grey> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
if (isset($_POST['eggrafi'])) header("Refresh: 1; URL=http://localhost/eggrafi.php");
}
?>
my kataxorisi.php is this but it seems that it dosent see the vars inside post.php even if i have include post.php in it!
<?php
include "post.php";
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
echo "<font size=5 color=Yellow>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('nikosgr_uk_db');
if (empty($onoma)) {echo "Äåí óõìðëÞñùóåò ôï ¼íïìá ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($eponymo)) {echo "Äåí óõìðëÞñùóåò ôï Åðþíõìï ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($til)) {echo "Äåí óõìðëÞñùóåò ôï ÔçëÝöùíï ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($email)) {echo "Äåí óõìðëÞñùóåò ôï E-mail ôïõ ößëïõ óïõ!<p>"; $i=1;}
if ($i!=0) exit;
mysql_query("INSERT INTO member_data VALUES ('$onoma', '$eponymo', '$til', '$email', '$user')");
$sql=mysql_query("SELECT * FROM member_data WHERE user='$user'");
$rows = mysql_num_rows($sql);
echo "<font size=5 color=Grey> Ç åããñáöÞ êáôá÷ùñÞèçêå <font color=Yellow> $user <br>";
echo "<font size=5 color=Grey> ÅðáöÝò ìÝ÷ñé óôéãìÞò: <font color=Yellow> $rows";
mail ("nik0s@mycosmos.gr", "Ï $user ìüëéò Ýêáíå êáôá÷þñçóç! ÅðáöÝò: $rows", "", "From: 007@spy.gr");
?>
Do u see the problem?
<?php
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
$onoma = $_POST['onoma'];
$eponymo = $_POST['eponymo'];
$til = $_POST['til'];
$email = $_POST['email'];
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('nikosgr_uk_db');
$sql=mysql_query("SELECT * FROM member");
while ($row = mysql_fetch_array($sql))
if (($_SERVER['PHP_AUTH_USER']==$row['user']) && ($_SERVER['PHP_AUTH_PW']==$row['pass']))
$i=1;
else
$i=0;
if ($i==0)
{
header('WWW-Authenticate: Basic realm="Ðïéüò åßóáé?"');
die ("<font size=5 color=Grey> Äåí åßóáé ìÝëïò ôçò ÁôæÝíôáò...ðñÝðåé ðñþôá íá ãñáöôåßò êáé ìåôÜ íá îáíÜñèåéò!!");
}
else
{
if (isset($_POST['kataxorisi'])) header("Refresh: 1; URL=http://localhost/kataxorisi.php");
if (isset($_POST['emfanisi'])) header("Refresh: 1; URL=http://localhost/emfanisi.php");
if (isset($_POST['metavoli'])) header("Refresh: 1; URL=http://localhost/metavoli.php");
if (isset($_POST['diagrafi'])) header("Refresh: 1; URL=http://localhost/diagrafi.php");
if (isset($_POST['eggrafi'])) header("Refresh: 1; URL=http://localhost/eggrafi.php");
}
?>
my kataxorisi.php is this but it seems that it dosent see the vars inside post.php even if i have include post.php in it!
<?php
include "post.php";
ob_start(); error_reporting(E_ALL); $i=0;
echo "<body background=pics/anemos.bmp>";
echo "<font size=5 color=Yellow>";
if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('nikosgr_uk_db');
if (empty($onoma)) {echo "Äåí óõìðëÞñùóåò ôï ¼íïìá ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($eponymo)) {echo "Äåí óõìðëÞñùóåò ôï Åðþíõìï ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($til)) {echo "Äåí óõìðëÞñùóåò ôï ÔçëÝöùíï ôïõ ößëïõ óïõ!<p>"; $i=1;}
if (empty($email)) {echo "Äåí óõìðëÞñùóåò ôï E-mail ôïõ ößëïõ óïõ!<p>"; $i=1;}
if ($i!=0) exit;
mysql_query("INSERT INTO member_data VALUES ('$onoma', '$eponymo', '$til', '$email', '$user')");
$sql=mysql_query("SELECT * FROM member_data WHERE user='$user'");
$rows = mysql_num_rows($sql);
echo "<font size=5 color=Grey> Ç åããñáöÞ êáôá÷ùñÞèçêå <font color=Yellow> $user <br>";
echo "<font size=5 color=Grey> ÅðáöÝò ìÝ÷ñé óôéãìÞò: <font color=Yellow> $rows";
mail ("nik0s@mycosmos.gr", "Ï $user ìüëéò Ýêáíå êáôá÷þñçóç! ÅðáöÝò: $rows", "", "From: 007@spy.gr");
?>
Do u see the problem?
$_POST is a superglobal. Try this:
Omit the line with include post.php in kataxorisi.php (etc).
Replace with:
$var1 = $_POST['var1'];
$var2 = ..etc.
Or, as was mentioned above, include kataxorisi.php (etc) rather than sending headers for them.
Omit the line with include post.php in kataxorisi.php (etc).
Replace with:
$var1 = $_POST['var1'];
$var2 = ..etc.
Or, as was mentioned above, include kataxorisi.php (etc) rather than sending headers for them.
Last edited by McGruff on Sat Feb 22, 2003 12:01 pm, edited 1 time in total.