Question

Ok I have a form on my page where people enter specific data. Then I want that data to be taken to a php page on my server that takes the form data and appends it to a url but either performs the function in a new window (I prefer the url to be hidden but not necessary) or performs the action without directing to the url (ie the url is opened but doesn't appear to the user)

Ex say I have 5 fields in the form so the base url is example.com/ and I want once the fields are entered to direct to example.com/field1&field2&field3&field4&field5

I have been able to get the action to perform with getelement codes but it opens in the same window and clears the form when they go back. I would prefer that the form stay so they can re-enter new information and continue to perform the url action.

This is what I have come up with so far for what Im looking for but It wont perform the action I get a server issue.

FORM:

<form method="post" action="http://gamerzacademy.com/trsrequest.php" target="blank">
<input type="text" name="ids" />
<input type="hidden" name="tab_clicked" value="Cafe" />
<input type="hidden" name="request_id" value="100172873469866" />
<input type="text" name="signed_request" />    <
<select name="gid" name="gid">
<option value="8631">Drums    </option>
<option value="8632">Guitar Strings    </option>
<option value="8633">Drumsticks    </option>
<option value="8634">Guitar Straps    </option>
<option value="8635">Microphones    </option>
<option value="8636">Speakers    </option>
<option value="8637">Handle Bar    </option>
<option value="8638">Spark Plug    </option>
<option value="8639">Leather Seat    </option>
<option value="8640">Motor Oil    </option>
<option value="8641">Metallic Paint    </option>
<option value="8642">Welding Torch     </option>
</select>
<input type="hidden" name="today" value="1" />
<input type="hidden" name="time" value="1345953369" />
<input type="hidden" name="ref" value="gift_today" />
<input type="hidden" name="cafe_token" value="OAlF7gSlMbQxAtBhvnprTyCLwuJFvNnvHwDcqeIrZ2YIofJzlyiZ2%2FVvflh2ih24wK1TsWdSyBH0xR205Q9+WwR%2F6ckIv4ozN4YdVvvWP2NmFlq95685hw%3D%3D" />

..... more fields .....

</form>

PHP

<?php
header("Location: http://fb-0.cafe.zynga.com/current/iframe//mfs_sent.php?'.'$_GET['ids'].'.'$_GET['tab_clicked'].'.'$_GET['request_id'].'.'$_GET['signed_request'].'.'$_GET['gid'].'.'$_GET['today'].'.'$_GET['time'].'.'$_GET['ref'].'.'$_GET['cafe_token'].'.'$_GET['from_page'].'.'$_GET['kingdom'].'.'$_GET['phylum'].'.'$_GET['uid'].'.'$_GET['sendkey'].'.'$_GET['mode'].'.'$_GET['trs_key'].'.'$_GET['stage'].'.'$_GET['mfs_time'].'.'$_GET['snood'].'.'$_GET['hash'].'.'$_GET['limiter_channel'].'.'$_GET['limiter_type'].'.'$_GET['ajax'].';"
?>

However I get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/15/9484115/html/trsrequest.php on line 2

Was it helpful?

Solution

Your header function should be like:

<?php
header("Location: http://fb-0.cafe.zynga.com/current/iframe//mfs_sent.php?".
urlencode($_POST['ids'])."&".
urlencode($_POST['tab_clicked'])."&".
urlencode($_POST['request_id'])."&".
urlencode($_POST['signed_request'])."&".
urlencode($_POST['gid'])."&".
urlencode($_POST['today'])."&".
urlencode($_POST['time'])."&".
urlencode($_POST['ref'])."&".
urlencode($_POST['cafe_token'])."&".
urlencode($_POST['from_page'])."&".
urlencode($_POST['kingdom'])."&".
urlencode($_POST['phylum'])."&".
urlencode($_POST['uid'])."&".
urlencode($_POST['sendkey'])."&".
urlencode($_POST['mode'])."&".
urlencode($_POST['trs_key'])."&".
urlencode($_POST['stage'])."&".
urlencode($_POST['mfs_time'])."&".
urlencode($_POST['snood'])."&".
urlencode($_POST['hash'])."&".
urlencode($_POST['limiter_channel'])."&".
urlencode($_POST['limiter_type'])."&".
urlencode($_POST['ajax']));
?>

Or you can do:

<?
$urlArgs = http_build_query($_POST);
header("Location: http://fb-0.cafe.zynga.com/current/iframe//mfs_sent.php?".$urlArgs);
?>

Note that this creates a parameter string that is key-value pairs though.

OTHER TIPS

You are using a string in double quotes ", but when concatenating you are using single quotes '.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top