Don Diego Posted April 24, 2007 Share Posted April 24, 2007 I have this code to send values to a file. The values are entries received from a form, but cannot be sent directly from the form. I need to send this data so it is received as if it were from the form, i.e., as in method=post form action. What needs to be added so that to the receiving file it looks identical to a form submission? <?php $siteUrl="http://receivingurl/receive.jsp"; $variablesToPost = array ( "first_name", "last_name" $postData = array(); foreach($variablesToPost as $variable) { $postData[$variable]=urlencode($_REQUEST[$variable]); } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $siteUrl); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); curl_exec ($curl); curl_close ($curl); ?> Link to comment https://forums.phpfreaks.com/topic/48409-send-from-a-file-as-if-from-a-form/ Share on other sites More sharing options...
Don Diego Posted April 24, 2007 Author Share Posted April 24, 2007 The process is: form-> intermediate file -> receiving file Since I can't get curl to work, I am trying this code in the intermediate file: <?php $Url="http://receivingurl.com/receive.jsp"; foreach ($_POST as $key => $value) { $Url .="'$key=$value'&"; } header ("Location: http://receivingurl.com/receive.jsp"); ?> However, I still get the same error message indicating that something is missing: 500 Servlet Exception java.lang.NullPointerException at javax.mail.internet.MimeUtility.checkAscii(MimeUtility.java:1286) at javax.mail.internet.MimeUtility.encodeWord(MimeUtility.java:613) at javax.mail.internet.MimeUtility.encodeText(MimeUtility.java:444) at javax.mail.internet.MimeMessage.setSubject(MimeMessage.java:793) at javax.mail.internet.MimeMessage.setSubject(MimeMessage.java:757) at norvaxbeans.MailUtils.sendMail(MailUtils.java:363) at _jsp._sendMail__jsp._jspService(sendMail.jsp:15) at com.caucho.jsp.JavaPage.service(JavaPage.java:60) at com.caucho.jsp.Page.pageservice(Page.java:570) at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:175) at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:115) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229) at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:277) at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:106) at com.caucho.jsp.PageContextImpl.forward(PageContextImpl.java:980) at _jsp._quoteMail__jsp._jspService(quoteMail.jsp:9) at com.caucho.jsp.JavaPage.service(JavaPage.java:60) at com.caucho.jsp.Page.pageservice(Page.java:570) at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:175) at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:188) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389) at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507) at com.caucho.util.ThreadPool.run(ThreadPool.java:433) at java.lang.Thread.run(Thread.java:619) -------------------------------------------------------------------------------- Resin Professional 3.0.19 (built Mon, 15 May 2006 05:00:32 PDT) Substituting header ("Location: $Url"); ?> results in an error message: "The request contains an illegal URL." What is wrong with my code? Link to comment https://forums.phpfreaks.com/topic/48409-send-from-a-file-as-if-from-a-form/#findComment-237301 Share on other sites More sharing options...
Don Diego Posted April 24, 2007 Author Share Posted April 24, 2007 I have corrected the code to this: <?php $Url="http://receivingurl.com/receive.jsp"; foreach ($_POST as $key => $value) { $url .="$key=" . urlencode($value) . "&"; } header ("Location: http://receivingurl.com/receive.jsp"); ?> However, I still get the same 500 servlet exception message. What is lacking with this code? Link to comment https://forums.phpfreaks.com/topic/48409-send-from-a-file-as-if-from-a-form/#findComment-237450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.