Solved

send post data

Posted on 2013-06-30
5
432 Views
Last Modified: 2013-06-30
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
Comment
Question by:jagguy
5 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39288141
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
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39288221
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
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39288245
If you are posting data using form then why do you need header location redirect you can add action in form.
0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39288261
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39288461
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
where is team.js? 3 26
How to show span when clicked on? 10 23
PHP Syntax Error 4 27
mysqli_connect error on wamp but not on remote server 8 27
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question