Jump to content

lightlydone

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Everything posted by lightlydone

  1. Hi Guys, After many hours research I still can't get my head around redirecting with header(location) and so am hoping someone out there would be kind enough to help me out? Basically i am posting form results to a url and waiting for a response. If the response is yes then i would like to redirect the user to a url that was sent back with the response, otherwise the results are posted to a 2nd url and if the response from that is yes i would like to redirect the user to a url that was sent back with that response etc... etc... <body> <?php if(isset($_POST['submit'])){ $email = $_POST['email']; $title = $_POST['title']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $ip = $_SERVER['REMOTE_ADDR']; $id = $_SESSION['id']; $date = date("Y-m-d"); $time = date("H:i:s"); //DO CURL STUFF if ($response == "true"){ $xml = new SimpleXMLElement($leadResult); $url = $xml->Redirect; header("Location: $url"); // if i get a positive response i want to redirect } else { //DO MORE CURL STUFF if ($response == "true") { $xml = new SimpleXMLElement($leadResult); $url = $xml->Redirect; header("Location: $url"); // if i get a positive response i want to redirect } else { ($response == "false"); } } // WRITE RESULTS TO DATABASE } ?> </body> I realise that this won't work, i'm just not sure why it won't work and, more importantly, how to make it work. Thanks in advance.
  2. Hi, I'm posting an XML string using curl and trying to read response using DOMDocument but the returned array is empty. Can anyone help with this? curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $leadXML); $leadResult = curl_exec($ch); curl_close($ch); $xmlDoc = new DOMDocument(); $xmlDoc ->load($leadResult); $x = $xmlDoc->getElementsByTagName("result"); $results = array(); foreach($x as $item){ $res = array(); if($item->childNodes->length) { foreach($item->childNodes as $i){ $res[$i->nodeName] = $i->nodeValue; } } $results[] = $res; } var_dump($results);
  3. Hi, I'm posting a form using curl: <?php //create the final string to be posted using implode() $post_str = implode ('&', $post_items); //Initialize cURL and connect to the remote URL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://leads..html' ); //Instruct cURL to do a regular HTTP POST curl_setopt($ch, CURLOPT_POST, TRUE); //Specify the data which is to be posted curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str); //Tell curl_exec to return the response output as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //Follow 302 redirect curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Timeout in seconds curl_setopt($ch, CURLOPT_TIMEOUT, 30); //verify https curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //Execute the cURL session $response = curl_exec($ch ); //Close cURL session and file curl_close($ch); echo $response; $resp = explode("\n\r\n", $response); $header = explode("\n", $resp[0]); echo "<pre>"; print_r($header); echo "</pre>"; ?> The response is: success: https://www-somesite.html or Array ( [0] => success: https://www-somesite.html ) My question is how to get the returned URL and redirect the user to it? Probably easy but seems to be beyond my very limited php knowledge. Thanks.
  4. Hi All, I'm sending an email with a link to a web page with a form on. <tr style="padding:10px;"> <td align="center"> <a style="text-decoration:none;" href="http://www.foo.co.uk/bar.php?id=123"> <img src="/header.jpg" border="0" style="display: block;" width="380" height="64" alt="Logo" /> </a> </td> </tr> I currently GET the id from the URL and add it to a hidden field in the form which then sends the ID to the database on submit so I know from which email the user came from to fill out the form. This doesn't always work as I guess some people move from the form page to look at other pages on my site then come back to fill in the form. I think I need to use SESSION to keep the id 'active' but cannot figure out how to GET the id from the URL and put it into a SESSION, alas I am struggling to even start and finish a basic SESSION. Thanks in advance, Ben.
  5. Hi All, I want users to be able to search my database and then use prepaid credits to view results. I am fairly new to mysql and really don't know where to start, cannot find anything on google. Could someone suggest where I might start/look or what I should be using in order to accomplish this? Many Thanks,
  6. Hi, I submit form data as an xml string - $strXML - using curl: curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, array('lead'=>$strXML)); $strResult = curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); The xml response is: <result> <posting_error>0</posting_error> <lead>0</lead> <valid>1</valid> <redirect_url>http://www.xxx.com</redirect_url> </result> and I need to redirect the user to <redirect_url>. I am trying the following: $xml = new SimpleXMLElement($strResult); header("Location:" . $xml->result->redirect_url); but with no joy. Could anyone suggest how I can achieve what I want? Thanks.
  7. yeah i think javascript is the way to go. Simshaun suggested: "On submit button click, use JS to create a hidden input (Q5) in the form and assign its value, then disable the day, month, and year fields so they are not submitted." But, alas, my js is very poor. Does anyone no how to do this?
  8. I will give it a go. Thanks for your help.
  9. Thats right. What i'm trying to achieve is similar to this: http://limegreensurvey.co.uk/index.php
  10. Im not inserting the data into a DB. Im sending the data to a URL: https://www.xxx.co.uk/xxx/en/members/livefeed.aspx?ref=vc_an_lf&q2=bob@bobmail.com&Q4=71&Q5=07-05-1980&Q7=Bob&Q8=Smith&Q9=1+Sesame+Street+London&Q10=sw123sh&Q262=3126&Q263=3127 All the fields are named q2=email, Q7=forename etc... and all work as above. I have to name the dob drop down fields as day, month, year so 3 names. i need to put all 3 of these values under 1 name, Q5, so the query string includes Q5=07-05-1990
  11. Im trying to pass form data into URL using $_GET, which i understand. The prob is that the dob fields are named <select name="day" id="select" style="width:70px;">, <select name="month" id="select2" style="width:70px;"> and <select name="year" id="select3" style="width:80px;"> so in the URL i get ?day=29&month=01&year=1927 when I need it to be ?dob=29-01-1927. So i guess i need to somehow OnSubmit get the 3 values and put them into 1 value=dob, then disable the day, month and year values so they don't appear in the URL as well. Does this make sense?
  12. Thanks for your reply. I will have to use the JS solution as I am already using header redirect to redirect to a thankyou page after the form has been submitted. I know absolutley no JS and cannot make sense of how to implement the JS solution (after 5 days of trying!!). Could anyone tell me how to do this? Thanks.
  13. Hi, I am sending data from a form to a URL using $_GET but I would also like the user to be redirected to a thankyou page which is a different URL. Does anyone know if this is possible? Thanks,
  14. Hi, I'm using $_GET to pass form data to a URL - http://localhost/projects/phpget/test.php?Q7=Dave&Q8=Smith&Q9=123+Road&Q10=ls11sl&Q2=dave%40hotmail.com&Q4=71&day=19&month=01&year=1995&Q263=3127&Q262=3126&x=99&y=24 All the form fields are named Qx and all are ok apart from dob. I've been trying to get the dob to be passed as dd-mm-yyyy with name of Q5, so in above example would be: http://localhost/projects/phpget/test.php?Q7=Dave&Q8=Smith&Q9=123+Road&Q10=ls11sl&Q2=dave%40hotmail.com&Q4=71&Q5=19-01-1995&Q263=3127&Q262=3126&x=99&y=24 I cannot name all 3 fields (date, month, year) as Q5 si i'm guessing that the 3 values need to be assinged to Q5 before the form is submitted?? Any help on this would be much appreciated as hours of trawling through google has not helped. Many thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.