PHP - Sockets: Could Not Accept Incoming Connection
Ahoy Sailor!
So I've just started making a Server Client based application in PHP, First time I've dabble in PHP for about a year so forgive me if I'm slightly rusty. But I get the "Could not accept incoming connection" error when my client try's to connect to my server. How cometh? <?php $host = "127.0.0.1"; $port = 405; set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // Networking area, Creating, Binding & finally listing $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); $out = "0;text\n"; socket_write($spawn, $out, strlen ($out)) or die("Could not write output\n"); ?> ^ Client<?php $addr="127.0.0.1"; $port=405; $timeout=0; $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $res = socket_connect($socket, $addr, $port); $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); $dat= socket_read($spawn, 1024) or die("Could not read input\n"); echo $dat; ?> Server^ _____________________ Anyone know? See Ya! Similar TutorialsHello. This is a follow up on a previous thread. I'm trying to redirect a socket connection via browser to another script or page but, I'm having a lot of problems trying to do it. I don't know if it can be done. Please guide me to where I can get some input on it. I've google about it and nothing exactly... The socket file looks like this: $host = "172.16.0.3"; $port = "200"; // don't timeout! set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP ) or die("Could not create socket\n"); // bind socket to port $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); // start listening for connections $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); while( true ){ // accept incoming connections // spawn another socket to handle communication $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); // read client input $input = socket_read($spawn, 1024) or die("Could not read input\n"); // clean up input string $input = trim($input); // reverse client input and send back $output = strrev($input) . "\n"; header('Location: http://www.cnn.com/'); $output = "hello there.. you're connected"; socket_write($spawn, $output, strlen ($output)) or die("Could not write output\n"); } // close sockets socket_close($spawn); socket_close($socket); ?> I put in the browser's addr bar: http://172.16.0.3:200 and get "hello there.. you're connected"... Can it be done?? Any suggestions? Thanks in advanced for your help. Hi, I'm building a flash environment for a small scale MMO game, and I need to employ the use of sockets so that users can interact with each other in real time (chat, battle, exploring, etc). I've done quite a bit of Googling, and haven't turned up much useful information. Maybe I'm looking for the wrong thing? Anyway, I have my own server, running Fedora 9 and Apache 2.0. I want to create a PHP "socket server" that runs almost as a process on my server, so that users can connect to it and pass data between each other instantly. I've looked through PHP's manual on the socket functions, and I'm fairly confident that I will be able to work with them just fine as soon as I actually have the socket server working.. So my question is, how exactly would I go about starting this process? I'm messing around on the command line right now and can't seem to get it to work? Thanks, nethnet Hello
I am looking for a way to log all incoming requests to a nusoap web service to a file.. any suggestions?
Thanks
Hello
I have a nusoap web service running, which is fine, but I need to send a new variable in the parameters which decides what database to use...
This is how I call the function:
$params = array( 'region' => '1' ); $response1 = $client->call('function1', array ($params)); // response will be in JSON I am running a godaddy linux server and would like to save the incoming emails into my database. I'm running a Simple Control Panel. This article about intercepting emails is exactly what I want to do. But its not working... http://tinsology.net/2009/01/intercepting-email-with-php/ It looks like there are quite a few pointers online but i haven't found a solution. Thanks in advance. Hey everyone... Been over a year or more since I have had seek help here but I have something that I just do not understand. I am submitting a from from one domain - www.mydomain.com - to a form handler on another domain - www.theirdomain.com all under https. The form data is getting to theridomain.com just fine, the other side is handling it properly and all is well there. The issue is they are taking the response they generate and shipping it out via cURL using the below (they were nice enough to share this with me). Code: [Select] $url = $_SESSION['request']['retUrl']; $fields = array( 'hash'=>rawurlencode($hash), 'responseText'=>rawurlencode($_SESSION['response']['responseText']), 'cid'=>rawurlencode($_SESSION['request']['cid']), 'name'=>rawurlencode($_SESSION['request']['name']), 'actCode'=>rawurlencode($_SESSION['response']['actCode']), 'apprCode'=>rawurlencode($_SESSION['response']['applCode']), 'Token'=>rawurlencode($_SESSION['response']['token']), 'req_number'=>rawurlencode($_SESSION['request']['req_number']), ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); if (isset($_SESSION['request']['Address1'])) { $Address = array( 'Address1'=>rawurlencode($_SESSION['request']['Address1']), 'Address2'=>rawurlencode($_SESSION['request']['Address2']), 'City'=>rawurlencode($_SESSION['request'][City']), 'State'=>rawurlencode($_SESSION['request'][State']), 'Zip'=>rawurlencode($_SESSION['request']['Zip']), 'Country'=>rawurlencode($_SESSION['request']['Country']), ); foreach($Address as $key=>$value) { $Address_string .= $key.'='.$value.'&'; } rtrim($Address_string,'&'); } $end = array( 'END'=>"END" ); foreach($end as $key=>$value) { $end_string .=$key.'='.$value; } rtrim($end_string,'&'); I have worked for almost a week and I CANNOT snag the incoming data! All I am trying to do is collect this and convert it into $_SESSION data for use on a success page. If any one has any thoughts or in site, please.... I am trying to post a feed file to ebay from our site via a PHP script, but I am new to this stuff. I found some instructions he http://pics.ebaystatic.com/aw/pics/pdf/us/file_exchange/File_Exchange_Advanced_Instructions.pdf The most important part of that PDF is: Quote Sample HTTP Post Request POST /path/to/upload/script HTTP/1.0 Connection: Keep-Alive User-Agent: My Client App v1.0 Host: https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES Content-Length: 256 --THIS_STRING_SEPARATES Content-Disposition: form-data; name="token" 12345678987654321 --THIS_STRING_SEPARATES Content-Disposition: form-data; name="file"; filename="listings.csv" Content-Type: text/csv ... contents of listings.csv ... --THIS_STRING_SEPARATES I tried to implement it using this code: <?php // GET THE FEED FILE $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => "", CURLOPT_USERAGENT => "website", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false, ); $ch = curl_init('https://www.mysite.com/pull_feed.php'); curl_setopt_array( $ch, $options ); $contents = curl_exec( $ch ); curl_close( $ch ); //----------------------------------------------------// //OPEN THE CONNECTION $conn = fsockopen('https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeProgrammaticDownload', 80); // START THE REQUEST fputs($conn, "POST ".$_SERVER['PATH_INFO']." HTTP/1.0"); fputs($conn, "Connection: Keep-Alive"); fputs($conn, "User-Agent: My Client App v1.0"); fputs($conn, "Host:"); fputs($conn, "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload"); fputs($conn, "Content-type: multipart/form-data;"); fputs($conn, "boundary=THIS_STRING_SEPARATES"); fputs($conn, "Content-Length: ".strlen($contents)); fputs($conn, "--THIS_STRING_SEPARATES"); fputs($conn, "Content-Disposition: form-data; name=\"token\""); fputs($conn, "MY_KEY_IS_HERE_000000000000000000000000"); fputs($conn, "--THIS_STRING_SEPARATES"); fputs($conn, "Content-Disposition: form-data; name=\"file\";"); fputs($conn, "filename=\"listings.csv\""); fputs($conn, "Content-Type: text/csv"); // SEND THE FILE fputs($conn, $contents); // END THE REQUEST fputs($conn, "--THIS_STRING_SEPARATES"); // GET THE RESULT while(!feof($conn)) { echo fgets($conn, 128); } // CLOSE CONNECTION fclose($conn); ?> UPDATE: I accidently had error reporting off. Whoops. It is giving me this error: Quote Warning: fsockopen() [function.fsockopen]: unable to connect to https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeProgrammaticDownload:80 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in C:\home\imafs\public_html\funad\ebay\send_feed.php on line 27 Followed by more errors resulting from that one. I have server #1 that host a php page with a form. I have server #2 that has a VPN connection to #1. I want the user to fill out the form on server #1 and on submit the data is sent to server #2 where it is processed and then an email is sent from server #2 with a confirmation. I do not want the user to be sent to the server#2 though. They can be sent to a thank you page. Can anyone enlighten me with the best function to use in this case or if it is even possible? THANKS Everyone! i have been working to works. but any time i use the method socket_read(); or socket_write(); my apache server gives me an error undefined method pls want could be responsible for this error. i am quite sure of the syntax I recently came across http://forums.phpfre...g-with-sockets/. Sockets? Never heard of them...
I looked at the PHP documentation http://php.net/manua...tro.sockets.php, and it tells how to implement them, but not really what their purpose is.
I then search a bit, and learned about their history http://en.wikipedia....erkeley_sockets, but still not really why they are used.
Okay, sockets are used to connect an application to a given port and IP, and PHP can be set up as either a socket host or socket client? Is this something like a SOAP server/client, but SOAP specifies a given port and protocol? Do sockets not necessarily specify a protocol?
Still a little fuzzy. Can anyone provide examples on where they might be used? BSD Sockets generally relies upon client/server architecture. For TCP communications, one host listens for incoming connection requests. When a request arrives, the server host will accept it, at which point data can be transferred between the hosts. UDP is also allowed to establish a connection, though it is not required. Data can simply be sent to or received from a host. The Sockets API makes use of two mechanisms to deliver data to the application level: ports and sockets. Ports and sockets are one of the most misunderstood concepts in sockets programming. All TCP/IP stacks have 65,536 ports for both TCP and UDP. There is a full compliment of ports for UDP (numbered 0-65535) and another full compliment, with the same numbering scheme, for TCP. The two sets do not overlap. Thus, communication over both TCP and UDP can take place on port 15 (for example) at the same time. A port is not a physical interface - it is a concept that simplifies the concept of Internet communications for humans. Upon receiving a packet, the protocol stack directs it to the specific port. If there is no application listening on that port, the packet is discarded and an error may be returned to the sender. However, applications can create sockets, which allow them to attach to a port. Once an application has created a socket and bound it to a port, data destined to that port will be delivered to the application. This is why the term socket is used - it is the connection mechanism between the outside world (the ports) and the application. A common misunderstanding is that sockets-based systems can only communicate with other sockets-based systems. This is not true. TCP/IP or UDP/IP communications are handled at the port level - the underlying protocols do not care what mechanisms exist above the port. Any Internet host can communicate with any other, be it Berkeley Sockets, WinSock, or anything else. "Sockets" is just an API that allows the programmer to access Internet functionality - it does not modify the manner in which communications occur. Reference: http://wiki.treck.co..._to_BSD_Sockets my current code: $host="127.0.0.1"; $port=7777; $timeout=5; $sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ; if (!is_resource($sk)) { exit("connection fail: ".$errnum." ".$errstr) ; } else { fputs($sk, "idkxd") ; $dati="" ; while (!feof($sk)) { $dati.= fgets($sk, 256); } } fclose($sk); echo($dati); The problem is that when I send data to the server, I never get a response. I do not believe that this is a server side problem as it works through a c# application and as well as when I turn the application off. This is what happens when I do not shut the server off: 1. I run the Server 2. I run the php script 3. Data is sent from PHP 4. Server Responds 5. PHP never gets the response A slightly different way that it does respond to php: 1. I run the Server 2. I run the php script 3. Data is sent from PHP 4. Server Responds 5. I turn off the server application 6. PHP receives data from the server... Please help, I am kind of new with php sockets. I'm trying to use sockets to see if I can connect to a chatroom. I got it started but not sure where to go from here. Code: [Select] <? $host = "79.99.135.253"; $port = 6667; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $data = "NICK OpenZelda"; $data .= chr(13); $data .= 'USER whoever "thegaminguniverse.com" "irc.thegaminguniverse.nl" :OZ Website'; $data .= chr(13); socket_connect($socket, $host, $port); socket_sendto($socket, $data, strlen($data), 0,$host,$port); socket_recv($socket, $buffer, 1024, 0); echo $buffer; ?> I managed to receive one message. However I know for a fact there were two messages sent back. So how do I set it up to keep receiving messages? I'm having issues working with sockets in PHP, I'm hoping someone can help.
I'm making an application in which I need to open my own socket connections. There are two specific features that I need:
I need to set a timeout for the connection attempt.
I need these connections to come from a custom IP address, and by that I mean that my server has more than one IP, and I need the socket connection to use an IP that is not the server's default internet connection port.
There are (as far as I know) two ways to open a socket connection. Both techniques meet a requirement and miss a requirement.
Option 1: I can use the function fsockopen( ) to open the connection. This function works great and let's me set a timeout for the connection itself. It's solid and reliable. However it has, as far as I can tell, no way to set the connection to come from a custom IP. All connections using this function come from the server's default IP address.
Option 2: The socket_create( ) / socket_connect( ) family of functions. These functions have a lot more options, they let you do a lot more. I can easily bind the socket to my server's secondary IP address so socket connections will come from it. HOWEVER as far as I can tell, these family of functions lack a connection timeout. You can set timeout for reads and timeouts for writes. But there doesn't seem to be a way to set a timeout for initiating the connection itself. Even setting the "default_socket_timeout" parameter doesn't have any effect on the connection time.
This type of question is a bit more technical than most PHP questions. But I'm hoping someone out there knows a way I can open sockets while meeting both of my two requirements. It's entirely possible that it is not possible, I know. But hopefully it can be done.
One thought I had was a way of using the second option, and wrapping the whole socket_connect( ) function inside of another function that sets a timeout, and would kill the socket_connect( ) function once the timeout was met. However, I don't know of any such system in PHP, this was only a concept theory.
How I open my sockets using fsockopen( ):
$sock = @fsockopen($ip,$port,$errno,$errstr,$timeout); I have a PHP application that runs as a daemon. the daemon uses fsockopen to connect to an external server. When the daemon is terminated, for instance during a reboot, it looks like the connections to the remote server are persistent. The admin of the remote server tells me that he sees some of these connections for days after a daemon instance on my server has dies. My first thought was to use a linux/unix signal to tell the daemon to close the connections before it dies, but I haven't found a way to do that yet. The daemon seems to respond only to a sig-kill. In a perfect world I'd discover a way for the daemon to always run a function before it shuts down - within the function I'd close the open connections. I'd be very appreciative if someone could point me at either a way to cause a function to execute upon receipt of a sigkill or else a way to cause the daemon to recognise and act on some other less aggressive signal. Thanks Hi, im trying to learn about socket in PHP but unfortunatly not getting anywhere fast. The main issue is, the reason i want to learn about them is for use on a project where i will be connecting to a server, not actually being one. So although i am interested in the server part, its not essential. But to test my php socket code, i need something to connect to for debugging? So i have tried to create (from tutorials) a php server but not had any luck at all, can anyone advise me on where to start here? I basically want a way to send a command from a php file over TCP/IP, but for now just want it to bounce back or get a response, is there any test servers out there or do i have to create one? I have my own windows web server running here next to me for all my testing. Thanks Andy Hello everyone, When someone starts an OC (Organised Crime) On my game, they invite 3 people. I was just testing it and found that everything is fine up until 1 point, the actual Inbox mail that the invited user gets. I can't click Accept or Reject? Here's the bit of code i have... Code: [Select] if (strip_tags($_POST['inv']) == "inv_we"){ $inv_username=strip_tags($_POST['inv_username']); $check = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='$inv_username'")); if ($check == "0"){ echo "No such user."; }elseif ($check != "0"){ if ($oc->we != "0"){ echo "You need to kick the Weapons expert before you invite someone else."; }elseif ($oc->we == "0"){ $invite_text=" <div align=center>You have been invited to join $username's Organised crime as the Weapons Expert, please choose one of the following options:<br> <input name=Decline type=submit id=Decline class=button value=Decline> | <input name=inv_button type=submit class=button id=inv_button value=Accept> </div><input type=hidden name=place value=we><input type=hidden name=oc_id value=$oc->id> "; mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` ) VALUES ( '', '$inv_username', '$inv_username', '$invite_text', '$date', '0' )"); echo "Weapons expert invited"; mysql_query("UPDATE oc SET we_inv='$inv_username' WHERE id='$oc->id'"); Hy ya'll! I've been trying to programatically read a string, but with no success. Code: [Select] function get_between($input, $start, $end) { $substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1)); return $substr; } $string = 'open -greetings hello -bye seeya'; echo get_between($string, '-greetings ', ' -bye'); // Output: hello echo get_between($string, '-greetings ', ' -'); // Outputs nothing echo get_between($string, '-greetings ', ' '); // Outputs nothing } It turns out that I don't know if "-bye" will always follow the value of "-greetings", so I can't call everything in between like the first way even tough it works fine in this example. Given that those values will always be a single word, I can use a whitespace as a delimiter to the right, but for some reason it won't return anything whatsoever, not even an error code. Any ideas how to get it done? Txs a bunch! Is there any way to have a PHP script automate the acceptance of a SSL certificate? I have a php script running on a windows machine in lighttpd. I have a question,
I have a fully working PHP mail form, but I can't seem to find one problem.
I thought it had something to do with the data cleansing like trim, htmlspecialcharacters and stripslashes, but unfortunately that wasn't.
My form has to be able to process characters like é è á ó etc.
Just that now when you fill those characters in it shows some weird code in the mail.
(é becomes é in the mail) and this is highly inconvenient.
Could any1 tell me how I can fix this?
this is the PHP code for my form: <?php if(isset($_POST['submit'])) { function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $error = ""; //Keep Values $Papillon_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Papillon') ? 'checked' : ''; $Phalene_checked = (isset($_POST['ras']) && $_POST['ras'] == 'Phalene') ? 'checked' : ''; $Babyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Babyklasse') ? 'checked' : ''; $Puppyklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Puppyklasse') ? 'checked' : ''; $Jeugdklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Jeugdklasse') ? 'checked' : ''; $Tussenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Tussenklasse') ? 'checked' : ''; $Openklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Openklasse') ? 'checked' : ''; $Kampioensklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Kampioensklasse') ? 'checked' : ''; $Fokkersklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Fokkersklasse') ? 'checked' : ''; $Veteranenklasse_checked = (isset($_POST['klasse']) && $_POST['klasse'] == 'Veteranenklasse') ? 'checked' : ''; //Validate form fields if (!empty($_POST['ras'])) { $ras = $_POST['ras']; } else { $error .= "- Klik het ras van uw hond aan. <br />";} if (!empty($_POST['kleur'])) { $kleur = test_input($_POST['kleur']); } else { $error .= "- Vul de kleur van uw hond in. <br />";} if (!empty($_POST['geslacht'])) { $geslacht = test_input($_POST['geslacht']); } else { $error .= "- Vul het geslacht van uw hond in. <br />";} if (!empty($_POST['naamhond'])) { $naamhond = test_input($_POST['naamhond']); } else { $error .= "- Vul de naam van uw hond in. <br />";} if (!empty($_POST['stamboom'])) { $stamboom = test_input($_POST['stamboom']); } else { $error .= "- Vul het stamboomnummer van uw hond in. <br />";} if (!empty($_POST['geboorte'])) { $geboorte = test_input($_POST['geboorte']); } else { $error .= "- Vul de geboortedatum van uw hond in. <br />";} if (!empty($_POST['klasse'])) { $klasse = $_POST['klasse']; } else { $error .= "- Klik de gewenste klasse aan. <br />"; } if (!empty($_POST['fokker'])) { $fokker = test_input($_POST['fokker']); } else { $error .= "- Vul de naam van de fokker in. <br />";} if (!empty($_POST['vader'])) { $vader = test_input($_POST['vader']); } else { $error .= "- Vul de naam van de vaderhond in. <br />";} if (!empty($_POST['moeder'])) { $moeder = test_input($_POST['moeder']); } else { $error .= "- Vul de naam van de moederhond in. <br />";} if (!empty($_POST['initialen'])) { $initialen = test_input($_POST['initialen']); } else { $error .= "- Vul uw initialen in. <br />";} if (!empty($_POST['eigachternaam'])) { $eigachternaam = test_input($_POST['eigachternaam']); } else { $error .= "- Vul uw achternaam in. <br />";} if (!empty($_POST['minitialen'])) { $minitialen = test_input($_POST['minitialen']);} if (!empty($_POST['meigachternaam'])) { $meigachternaam = test_input($_POST['meigachternaam']);} if (!empty($_POST['straat'])) { $straat = test_input($_POST['straat']); } else { $error .= "- Vul uw straatnaam in. <br />";} if (!empty($_POST['huisnr'])) { $huisnr = test_input($_POST['huisnr']); } else { $error .= "- Vul uw huisnummer in. <br />";} if (!empty($_POST['postcode'])) { $postcode = test_input($_POST['postcode']); } else { $error .= "- Vul uw postcode in. <br />";} if (!empty($_POST['plaats'])) { $plaats = test_input($_POST['plaats']); } else { $error .= "- Vul uw woonplaats in. <br />";} if (!empty($_POST['land'])) { $land = test_input($_POST['land']);} if (!empty($_POST['email'])) { $email = $_POST['email']; if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){ $error .= "- U heeft een ongeldig e-Mail adres ingevuld. <br/>";} } else { $error .= "- Vul uw e-Mail adres in. <br />";} if (!empty($_POST['telefoon'])) { $telefoon = test_input($_POST['telefoon']);} if (!empty($_POST['peradres'])) { $peradres = test_input($_POST['peradres']);} if (!empty($_POST['eerstehond'])) { $eerstehond = test_input($_POST['eerstehond']);} if (!empty($_POST['verderehond'])) { $verderehond = test_input($_POST['verderehond']);} if (!empty($_POST['babypup'])) { $babypup = test_input($_POST['babypup']);} if (!empty($_POST['koppelklas'])) { $koppelklas = test_input($_POST['koppelklas']);} if (!empty($_POST['koppelhond1'])) { $koppelhond1 = test_input($_POST['koppelhond1']);} if (!empty($_POST['koppelhond2'])) { $koppelhond2 = test_input($_POST['koppelhond2']);} if (!empty($_POST['totaal'])) { $totaal = test_input($_POST['totaal']);} if (!empty($_POST['naamjh'])) { $naamjh = test_input($_POST['naamjh']);} if (!empty($_POST['leeftijdjh'])) { $leeftijdjh = test_input($_POST['leeftijdjh']);} if (!empty($_POST['akkoord'])) { $akkoord = $_POST['akkoord']; } else { $error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";} //no errors were set if(empty($error)) { //code to send the email //The form has been submitted, prep a nice thank you message $output = '<center><b>Het Inschrijfformulier is verzonden <br />We zullen de gegevens verwerken <br/><u>Papillon & Phalène Vereniging Nederland</u></b></center>'; //Set the form flag to no display (cheap way!) $flags = 'style="display:none;"'; //Deal with the email $to = 'joke@pp-vn.nl'; $from = $_POST['email']; $subject = 'Inschrijfformulier'; $message = 'From: ' .$initialen .' ' .$eigachternaam . ' <' . $email . '>' ."\n\n"; $message .= 'Ras: ' .$ras ."\n"; $message .= 'Kleur: ' .$kleur ."\n"; $message .= 'Geslacht: ' .$geslacht ."\n"; $message .= 'Naam v/d hond: ' .$naamhond ."\n"; $message .= 'Stamboomnummer: ' .$stamboom ."\n"; $message .= 'Geboortedatum: ' .$geboorte ."\n"; $message .= 'Klasse: ' .$klasse ."\n"; $message .= 'Naam Fokker: ' .$fokker ."\n"; $message .= 'Naam Vaderhond: ' .$vader ."\n"; $message .= 'Naam Moederhond: ' .$moeder ."\n"; $message .= 'Eigenaar: ' .$initialen .' ' . $eigachternaam ."\n"; $message .= 'Mede-eigenaar: ' .$minitialen .' ' .$machternaam ."\n"; $message .= 'Adres: ' .$straat .' ' .$huisnr .' ' .$postcode .' ' .$plaats .' ' .$land ."\n"; $message .= 'Telefoon: ' .$telefoon ."\n"; $message .= 'e-Mail: ' .$email ."\n"; $message .= 'Per Adres: ' .$peradres ."\n"; $message .= 'Inschrijving eerste hond: ' .$eerstehond . "\n"; $message .= 'Andere honden ingeschreven: ' .$verderehond . "\n"; $message .= 'Baby- Puppyklasse: ' .$babypup . "\n"; $message .= 'Koppelklasse: ' .$koppelklas . "\n"; $message .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n"; $message .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n"; $message .= 'Totaalbedrag: ' .$totaal . "\n"; $message .= 'Naam Juniorhandler: ' .$naamjh . "\n"; $message .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n"; $message .= 'Akkoord: ' .$akkoord ."\n"; $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name']))); $filename = $_FILES['file']['name']; $boundary =md5(date('r', time())); $headers = "From: fransien@pp-vn.nl"; $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\""; $message="This is a multi-part message in MIME format. --_1_$boundary Content-Type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary Content-Type: text/plain; charset=\"iso-8859-1\" Content-Transfer-Encoding: 7bit $message --_2_$boundary-- --_1_$boundary Content-Type: application/octet-stream; name=\"$filename\" Content-Transfer-Encoding: base64 Content-Disposition: attachment $attachment --_1_$boundary--"; mail($to, $subject, $message, $headers); mail($from, $subject, $message, $headers); } else { //display errors echo '<center><span class="error"><strong>Uw bericht is niet verstuurd<br/> De volgende fout(en) zijn opgetreden:</strong><br/>' . $error . '<br /><strong><u>Pas op: Bij een foutmelding indien nodig Kampioenstitel opnieuw toevoegen!!</u></strong></span></center>'; } } ?> |