/    Sign up×
Community /Pin to ProfileBookmark

Im confused…

well i got some php codes and tried to start using them. They didnt work… little did i know u needed a program to use PHP(or am i wrong?). Installed xampp… dont know what im doing… read the read me. got even more confused… tried messing around with it and now im totally confused.

Any suggestions? Do i need a program to use PHP or not? What am i doing wrong?

Now when i click a submit button that has action=”A.php” it sends me a download prompt.

to post a comment
PHP

21 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJul 20.2005 — yes you have to put the php file in your web root directory, probably in the xampp directory

but you really should take a look at the infomation files that came with xampp and maybe the FAQ on the page,

and definitely take a look at www.php.net
Copy linkTweet thisAlerts:
@BervanauthorJul 22.2005 — what do you meant the web root directoty? the directory in which the HTML is located? and then also in the xampp directory? please explain more im still confused.... checked php.net looked through some of the stuff there... didnt find anything that looked helpful, for the problem im having anyways. Is there another PHP program i could use? xampp has alot, and i cant get it to start.... read some faq's on it and it didnt help, the dos files that i ran never completed as the faq said it would.
Copy linkTweet thisAlerts:
@stephan_gerlachJul 22.2005 — I hope this will help.

Once you have installed xampp you need to start apache and also mysql ( if you want to use the database ). You can do that depending on which version you have in different ways. Just go into the xampp folder and look if there are files like apache_start.bat or mysql_start.bat. You need to leave the windows open though. To stop them just double click on the apache_stop.bat and mysql_stop.bat.

To see if apache is working just open your web brower and enter http://localhost/ If you do that you should be able to see some webstuff about xampp.

Just double click them and this should start apache and mysql. The php scripts need to be in the folder called htdocs. I would suggest that you create a new folder in the htdocs folder like web and in this folder you can put your own stuff. I would also create a new folder for every project you are working on within the web folder.

hope this helps a little bit
Copy linkTweet thisAlerts:
@BervanauthorJul 22.2005 — K im trying that right now... also i may have screwed up... in trying to get PHP to work on my own... i used "always open using this type of file" and clicked on " "... will this screw my PHP days on my computer? or does it even matter? if it does matter, does anyone know how to fix it?

-Thanks for all the help
Copy linkTweet thisAlerts:
@bokehJul 22.2005 — I tried xampp and found it very unstable. In the end I returned to AppServ which is excellent.
Copy linkTweet thisAlerts:
@BervanauthorJul 22.2005 — Downloading AppServ right now...

As Stephan.Gerlach said

"The php scripts need to be in the folder called htdocs."

That was for xampp... what folder do they need to be in for AmpServ? I'll look for a folder on my own... thanks for the help ?
Copy linkTweet thisAlerts:
@bokehJul 22.2005 — OK! Make sure the version you are downloading is either 2.5.4a or 2.4.2 depending which version of apache and php you want. Load it first and then I will tell you what to do if you have problems. The root directory is c:/appserv/www if you do the standard install. Put your files there and call them like so. http://localhost/filename.php
Copy linkTweet thisAlerts:
@BervanauthorJul 22.2005 — what do u mean "and call them like so. http://localhost/filename.php" so i need to right click and rename them "http://localhost/filename.php"? or do i need to go into the html i have and make it ACTION="http://localhost/filename.php">? ill try what i just said... i might have answered ymy own problem ? hey also... when i host my site... what are some web host's that support PHP? i might need to make a new thread and post "hey to help me and everyone else post webhosts that support PHP here"
Copy linkTweet thisAlerts:
@BervanauthorJul 22.2005 — I set the ACTION in my HTML ="http://localhost/PHPTEST.php and this is what i got.

http://localhost/PHPTEST.php

The page cannot be found

HTTP 404 - File not found

Internet Explorer

What did i do wrong?
Copy linkTweet thisAlerts:
@BeachSideJul 22.2005 — did you name the file phptest.php or PHPTEST.php?

Spelling and capitalization make a difference

Also are you sure that everything is running properly? Have you tried http://localhost yet NOT in the action but directly in the browser?
Copy linkTweet thisAlerts:
@bokehJul 22.2005 — Put the file where I said and then open your browser. Enter http://localhost/filename.php in the address bar and press send. Obviously 'filename' should match the name of the file you want to open.
Copy linkTweet thisAlerts:
@BervanauthorJul 23.2005 — "did you name the file phptest.php or PHPTEST.php?

Spelling and capitalization make a difference"

Spelled all caps so it would make it easy for me with the HTML codes as well... i leave the capslock on.

http://localhost directly in the browser works fine... though the read me link in that browser doesnt work?

"Enter http://localhost/filename.php in the address bar and press send. Obviously 'filename' should match the name of the file you want to open."

Entered in http://localhost/PHPTEST.php got a HTTP 404 Error Not found... its in the /www folder...

I thought to myself... maybe its just THAT php... tried another 1. Same thing.

Entered in http://localhost/testingthis.php got a HTTP 404 Error Not found...


Like I said before...

"... also i may have screwed up... in trying to get PHP to work on my own... I used 'always open using this type of file"...

I clicked on a file that was in one of the xampp folders callled 'php.exe' I believe and now its trying to find that program and it cant cause I deleted it with xampp...

Is there a .exe in AppServ that I can change it to so it will not keep on trying to open all my .php's with an .exe that does not exist? I may need a 'Windows' Guro to help?

-Thanks
Copy linkTweet thisAlerts:
@bokehJul 23.2005 — Dont try changing any configuration settings. All you will do is stop it working and later you will not know how you broke it. It works out of the box as you have confirmed. When you run http://localhost/ what did you get?

Go to c:/appserv/www directory and rename index.php to index 1.php Now when you run localhost you will be able to see a directory listing. Go down the listing and select your file. If it is not there you have placed it in the wrong place.

Don't change or do anything else or you will probably break it.
Copy linkTweet thisAlerts:
@BervanauthorJul 24.2005 — On the only 2 php's i have i got these 2 different response's

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:AppServwwwWebsitesPHPTEST.php on line 3


Parse error: syntax error, unexpected T_IF in C:AppServwwwWebsitesformtarget.php on line 10
Copy linkTweet thisAlerts:
@bokehJul 24.2005 — Well that's because both of them contain errors. Post the scripts and maybe someone can point them out.
Copy linkTweet thisAlerts:
@BeachSideJul 24.2005 — <Offtopic>

Bokeh - That AppServ is Fantastic! Good call man! I am reluctant to use an all in one server install kit. I run Windows Server 2003 Enterprise and have it all set up and whatnot. Runs like a champ ? But I wish I would have known about this thing back then I spent at least a day setting up PHP alone (Set it up as a SAPI module it was frustrating)

Thanks for the tip ?
Copy linkTweet thisAlerts:
@BervanauthorJul 26.2005 — Here's 1

[code=php]//formTarget.php
<?php
//check the $_POST variable for one of your form elements to see if the form has been submitted
if(isset($_POST["First_Name"])) { //then the form has been submitted
$filename = 'formtarget.txt'; //enter the real filename here
//construct a string to write into the file.
$somecontent = $_POST["First_Name"]."t".$_POST["Last_Name"]."n"; $_POST["State"]."n".

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
} [/code]


Heres the other...

[code=php]<?php
$filename = 'test.txt';
$somecontent = "$_POST["First_Name"]n $_POST["Last_Name"]";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}
?> [/code]


OK... there they are... i think they are the same thing... i tried to edit them abit... heres my html to help out more... i have 2 html's... but they are identical except for where i put the .php information.

[code=html]<html>
<head>
<title>TITLE</title>
</head>
<body>
<FORM METHOD=POST ACTION="http://localhost/PHPTEST.php">
<TABLE BORDER=0 WIDTH="75%" HEIGHT=90>
<TR>
<TD WIDTH=70>First Name</TD>
<TD width=120><INPUT TYPE="text" NAME="First_Name" SIZE="30"></td>
</TR>
<TR>

<TD WIDTH=70>Last Name</TD>
<TD WIDTH=120><INPUT TYPE="text" NAME="Last_Name" SIZE="30"></TD>
</TR>
<TR>
<TD WIDTH=70>Address 1</TD>
<TD WIDTH=120><INPUT TYPE="text" NAME="Address_1" SIZE="30"></TD>
</TR>
<TR>
<TD WIDTH=70>Address_2</TD>
<TD WIDTH=120><INPUT TYPE="text" NAME="Address_2" SIZE="30"></TD>
</TR>
<TR>
<TD WIDTH=70>City</TD>
<TD WIDTH=120><INPUT TYPE="text" NAME="City" SIZE="30"></TD>
</TR>
<TR>
<TD WIDTH=70>State</TD>
<TD WIDTH=120><SELECT NAME="State" SIZE="1">
<OPTION VALUE="AL"> Alabama
<OPYION VALUE="--">(I HAVE ALL THE STATES HERE BUT I FIGURED ID TAKE THEM OUT TO NOT ANNOY EVERYONE :)
<OPTION VALUE="WY"> Wyoming</SELECT></TD>
</TR>
<TR>
<TD WIDTH=70>Zip/Postal Code</TD>
<TD WIDTH=120><input type=text name="zip_code"></TD>
</TR>
<TR>
<TD WIDTH=70>Phone Number</TD>
<TD WIDTH=120><input type=text name="phone_no"></TD>
</TR>
</TABLE>
<INPUT TYPE="Submit" Value="Submit">
</form>
</body>
<html>[/code]



Ok... well... since everyone has forgotten what this thread was about ill state what i want?. I want the php to write all the information from the html, when they hit submit button, to a file in the directory of the HTML and when they hit the submit button I want it to send them to a "thank you for your input" page, and if they havent typed in information needed I want it to tell them... I dont care how(directing to another html saying "you have ____ information missing please go back or whatever is easier that you know of).

Thats about it... Thanks for everyone thats attempting to help me(the newb) :p
Copy linkTweet thisAlerts:
@BervanauthorJul 27.2005 — anyone there? i guess some of u forgot about me? just posting this message to bring it back up to the front(hope im not annoying anyone by doing this)
Copy linkTweet thisAlerts:
@BeachSideJul 28.2005 — No one is going to just write the script for you man! Those snippits that you copy and pasted from php.net are very good starting points to do what you want the code to do. Have you even tried them?

I will tell you that you need to probably use the second one there as you haven't modified it so much. You will also need to change this line...
[code=php]
$somecontent = "$_POST["First_Name"]n $_POST["Last_Name"]";

// change it to this
$somecontent = "$_POST['First_Name']n $_POST['Last_Name']";
[/code]

Be careful with using capital letters! First_Name is not the same as [B]first_Name[/B] or [B]First_name[/B] or even [B]first_name[/B]
Copy linkTweet thisAlerts:
@BervanauthorJul 31.2005 — BeachSide-
No one is going to just write the script for you man! Those snippits that you copy and pasted from php.net are very good starting points to do what you want the code to do. Have you even tried them?[/QUOTE]

Duh Ive tried them... They didnt work. Ive alread got them written... i dont need anyone to write em... i need them checked out for errors cause they dont work. :mad:

Bokeh said-
Well that's because both of them contain errors. Post the scripts and maybe someone can point them out.[/QUOTE]

So i posted them... Beachside, you really should read the posts before :p

I'll try that revision you posted and come back.
Copy linkTweet thisAlerts:
@BervanauthorJul 31.2005 — Here's my problem... i filled in the information for the form... clicked the submit button... and it sent me straight to "C:AppServwwwWebsitesPHPTEST.php" which just showed me all of the text in an IE Browser.... Does this make sense? Both mysql_start and apache_start were running... Im so confused STILL!!
×

Success!

Help @Bervan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...