I'm Running xampp on windows 7 64 bit Proffessionial, I've searched google and everywhere, I just keep finding wanna be form builders that are super lame... I'm trying to host this form for our intranet, ( internal network ).

My question is what do I need to replace in here to get it so it works with local host...

I have and Idea but i think it won't work...

Do i replace this "www.domainname.com" local host? or http://localhost/folder ?

I'm also confused on this part: " fputs($connection, "POST /target_url.php HTTP/1.1\r\n");"

What do i do for the target_url.php?

//create array of data to be posted
$post_data['firstName'] = 'Name';
$post_data['action'] = 'Register';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//we also need to add a question mark at the beginning of the string
$post_string = '?' . $post_string;
//we are going to need the length of the data string
$data_length = strlen($post_string);
//let's open the connection
$connection = fsockopen('www.domainname.com', 80);
//sending the data
fputs($connection, "POST  /target_url.php  HTTP/1.1\r\n");
fputs($connection, "Host:  www.domainname.com \r\n");
    "Content-Type: application/x-www-form-urlencoded\r\n");
fputs($connection, "Content-Length: $data_length\r\n");
fputs($connection, "Connection: close\r\n\r\n");
fputs($connection, $post_string);
//closing the connection

I'm making a form in dreamwaver, but i need the user to be able to fill out the form, hit submit, then the data gets submitted to the database, and an admin can look up the results, through another page or the database its self.

4 Years
Discussion Span
Last Post by jacob.lemelincarrier

You are right, looking at this you want to replace:

fsockopen("www.domainname.com, 80);


fsockopen("http://localhost", 80); //or
fsockopen(", 80);

As far as it goes for /target_url.php, that is simply where the data will be posted assuming target_url.php is located in your root directory of your server since you sent the data to localhost and not a subdirectory of localhost. This simply means, when the server serves you this page, the connection sent the data to this page with HTTP 1.1.

Votes + Comments
Helpful :)

so for example the target url thing lets say i had a page called data.php

fputs($connection, "POST /target_url.php HTTP/1.1\r\n"); would post data to that page? or what?

Also will this work to post the data to the database table when i hit the button? or am I missing much more?

Edited by .kaine


Yes, this will post data to that page, and you will be able to access it with php through $_POST superglobal variable. It will not post the data inside the database though, you will need to run queries on whatever database you are using, with that data in the $_POST array.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.