Solved

send post data

Posted on 2013-06-30
5
405 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 30

Expert Comment

by:Marco Gasi
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
If you are posting data using form then why do you need header location redirect you can add action in form.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
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 82

Accepted Solution

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now