1 Replies - 2780 Views - Last Post: 20 March 2010 - 02:15 PM Rate Topic: -----

#1 Guest_Hikari*


Reputation:

PHP/WAMP help, web browser hang when loading localhost server

Posted 20 March 2010 - 02:08 PM

hey guys, im having some problem. im somewhat new to PHP programming, and me and my friend tried to make a facebook like application, it creates directories when you register an account and puts all details on that folder(for your profile)

but I created a profile php file that accesses the username(since that was also the folder name)this is assuming all inputs are correct. but when i create a new file, something goes wrong. after i close the web browser, everytime i load localhost using WAMP as a server, it keeps giving me an error on the web browser, status access violation or something, it ends up terminating the browser and i cannot determine the cause. please help if you can. thanks!

<?php

	$error = false;
	$errorfragment = "?";
	if (isset($_POST['newusername'][0]) == false){
		$error = true;
		$errorfragment = $errorfragment."nonewusername=true&";
	}
	
	$file = fopen("usernames.txt", "r");
	$usernames = fgets($file);
	$usernames = trim($usernames);
	while($usernames != false){
		if ($usernames == $_POST['username']){
			$error = true;
			$errorfragment = $errorfragment."takenusername=true&";
		}
		$usernames=fgets($file);
	}
	fclose($file);

	if (strcmp($_POST['newpassword'],$_POST['newpassword2']) != 0)
		{
		$error = true;
		$errorfragment = $errorfragment."passwordmismatch=true&";
		}
	else
		{
		if (isset($_POST['newpassword'][0]) == false)
			{
			$error = true;
			$errorfragment = $errorfragment."nonewpassword=true&";
			}
		if (isset($_POST['newpassword2'][0]) == false)
			{
			$error = true;
			$errorfragment = $errorfragment."nonewpassword2=true&";
			}
		}
	
		
	if ($error == true){
		header("Location:index.php".$errorfragment."newusername=".$_POST['newusername']);
	}
	else{
		mkdir("/".$_POST['newusername'],0777);
		
		
		
		$name1 = "(Please insert Surname)\n";
		$name2 = "(Please insert First Name)\n";
		$name3 = "(Please insert Middle Name)\n";
		$name4 = "(Please insert Birthday)\n";
		$name5 = "(Please insert Birthplace)";

		$loadfile = $_POST['newusername']."/Names.txt";
		//$loadfile = 'Names.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fwrite($fh, $name3);
		fwrite($fh, $name4);
		fwrite($fh, $name5);
		fclose($fh);
		
			$name1 = "(Please insert Nickname)\n";
			$name2 = "(Please insert Cellphone)\n";
			$name3 = "(Please insert Home Address)\n";
			$name4 = "(Please insert Landline Number)\n";
			$name5 = "(Please insert College Address)\n";
			$name6 = "(Please insert College Number)";
		
		$loadfile = $_POST['newusername']."/Contacts.txt";
		//$loadfile = 'Contacts.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fwrite($fh, $name3);
		fwrite($fh, $name4);
		fwrite($fh, $name5);
		fwrite($fh, $name6);
		fclose($fh);

		
			$name1 = "(Please insert Mother's Name)\n";
			$name2 = "(Please insert Father's Name)\n";
			$name3 = "(Please insert Siblings)";
		
		
		$loadfile = $_POST['newusername']."/Family.txt";
		//$loadfile = 'Family.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fwrite($fh, $name3);
		fclose($fh);
		

			$name1 = "(Please insert Elementary Graduated)\n";
			$name2 = "(Please insert Elementary Attended)";
		

		$loadfile = $_POST['newusername']."/EducationElem.txt";
		//$loadfile = 'EducationElem.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fclose($fh);
		

			$name1 = "(Please insert High School)\n";
			$name2 = "(Please insert Sections)\n";
			$name3 = "(Please insert Clubs)\n";
			$name4 = "(Please insert Participation)";
		
		
		
		$loadfile = $_POST['newusername']."/EducationHigh.txt";
		//$loadfile = 'EducationHigh.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fwrite($fh, $name3);
		fwrite($fh, $name4);
		fclose($fh);
		

			$name1 = "(Please insert Current University)\n";
			$name2 = "(Please insert Previous University)\n";
			$name3 = "(Please insert Student Number)\n";
			$name4 = "(Please insert Current Degree Course)\n";
			$name5 = "(Please insert Previous Degree Course)\n";
			$name6 = "(Please insert Degree Major)\n";
			$name7 = "(Please insert Bloc)";
		
		
		$loadfile = $_POST['newusername']."/EducationCollege.txt";
		//$loadfile = 'EducationCollege.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fwrite($fh, $name2);
		fwrite($fh, $name3);
		fwrite($fh, $name4);
		fwrite($fh, $name5);
		fwrite($fh, $name6);
		fwrite($fh, $name7);
		fclose($fh);
		
		$name1 = "(Please insert Affiliations)";
		
		$loadfile = $_POST['newusername']."/Affiliation.txt";
		//$loadfile = 'Affiliation.txt';
		$fh = fopen($loadfile, 'w') or die("Can't open file");
		fwrite($fh, $name1);
		fclose($fh);
		
		
		
		$loadfile = "loginzfowz.txt";
		$fh = fopen($loadfile, "a");
		fwrite($fh,$_POST['newusername']."\n");
		fwrite($fh,$_POST['newpassword']."\n");
		fclose($fh);
		
		$file = 'DefaultIcon.gif';
		$newfile = $_POST['newusername']."/".'DefaultIcon.gif';
		
		if (!copy($file, $newfile)) {
				echo "failed to copy $file...\n";
		}

		$imagewriter = $_POST['newusername']."/Images.txt";
		$fh = fopen($imagewriter, 'w') or die("Can't open file");
		fwrite($fh, 'DefaultIcon.gif');
		fclose($fh);
		
		
		$loadfile = "usernames.txt";
		$fh = fopen($loadfile, "a");
		fwrite($fh, $_POST['newusername']."\n");
		fclose($fh);
		
		
		session_start();
		$_SESSION['name'] = $_POST['newusername'];
		
		//header function, redirect to main menu
		header("location:editforms.php");
		}
?>


Is This A Good Question/Topic? 0

Replies To: PHP/WAMP help, web browser hang when loading localhost server

#2 Guest_Hikari*


Reputation:

Re: PHP/WAMP help, web browser hang when loading localhost server

Posted 20 March 2010 - 02:15 PM

hi its me again, my code is somewhat messy. but the first part validates the users identity. them it creates a folder in his username(assuming the input is correct). then it writes the files neccessary for my program to run.(the many file open). i just dont know where the error occurs. i was thinking of trying to run the profile script using different browsers and access different accounts in my program using the username as directory openers, but it just wont let me inside the WAMP server, i have never touched anything other than PHP on that setup so im guessing its my code that did the error.
Was This Post Helpful? 0

Page 1 of 1