• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

send post data

Hi,

How do I send Post data? This didnt work as the data doesnt get picked up with Post

 header("location:checkreg.php?myusername=" . $myusername . "&mypassword=" . $mypassword ."&mysurname=" . $mysurname . "&myfirstname=" . $myfirstname . "");

-------------
checkreg.php

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$mysurname=$_POST['mysurname'];
$myfirstname=$_POST['myfirstname'];
0
jagguy
Asked:
jagguy
1 Solution
 
Marco GasiFreelancerCommented:
You can't use header to pass post data or parameters (http://it1.php.net/manual/en/function.header.php). You should put them in a session (http://it1.php.net/manual/en/book.session.php):

session_start();

$_SESSION['myusername']=$_POST['myusername'];
$_SESSION['mypassword']=$_POST['mypassword'];
$_SESSION['mysurname']=$_POST['mysurname'];
$_SESSION['myfirstname']=$_POST['myfirstname'];

 header("location:checkreg.php");

And in checkreg.php:

$myusername=$_SESSION['myusername'];
$mypassword=$_SESSION['mypassword'];
$mysurname=$_SESSION['mysurname'];
$myfirstname=$_SESSION['myfirstname'];

That's all
0
 
Ray PaseurCommented:
Please show us the script that you're using to send the post data.  If you've got an HTML form, it should be easy to give you a tested and working example.

See: http://php.net/manual/en/tutorial.forms.php
0
 
Jagadishwor DulalBraces MediaCommented:
If you are posting data using form then why do you need header location redirect you can add action in form.
0
 
Julian HansenCommented:
Why do you want to post on a redirect?

Two options - if you have to post then create a dummy page with a form and the vars you want posted with some javascript to auto submit the form. Clumsy but then you are not doing something generally considered normal.

Failing that - you can use the $_SESSION to save the vars before doing a standard header redirect to the target page - which can then pull the values it needs from the session.

All of this is up in the air though - without knowing what you are trying to do the correct solution might be something else completely - such as using CURL or similar.
0
 
Dave BaldwinFixer of ProblemsCommented:
Not in "$_POST" but it would be there for $_GET.  $_GET is the query string info in a URL.

$myusername=$_GET['myusername'];
$mypassword=$_GET['mypassword'];
$mysurname=$_GET['mysurname'];
$myfirstname=$_GET['myfirstname'];
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now