Jump to content

Help, how would i do this;


Minimeallolla

Recommended Posts

I'm trying to: when the submit button is hit, store data in a file (already created upon registration) and then show the files content. I have a few problems. The file im showing the content of cannot be found \= even though it was created using the same line as this..

 

 

if (isset($_POST['submit'])) { 
$firstname = ($_POST['firstname']);
$lastname = ($_POST['lastname']);
include ("cookieusername.php");

$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
while($info = mysql_fetch_array( $check )) 
$filename = "***/$username.info.php" or exit("Unable to open file!");
$handle = @fopen($filename, 'x+')or die(mysql_error()); 
$content = "lololo";
@fwrite($handle, $content)or die(mysql_error()); 
@fclose($filename);
}
include ("***/$username.info.php")or die(mysql_error()); 
?>

Link to comment
Share on other sites

ok ill just copy and paste the whole file but change the names of the directory for safety lol im paranoid ><

ok well you only really need the part i first posted but this is all incase it makes a difference.. i posted my goal in the first post..

 

 

and for the content, i wanted to make it eg. $firstname. but that didnt work so i changed it to lolo and that dindt work so ergh ><

<?php
include ("database.php");
include ("cookieusername.php");

?>
<title>
MySite - Profile - <?php echo $username ?>
</title>

<style type="text/css">
<!--
A:link { COLOR: black; TEXT-DECORATION: none; font-weight: normal }
A:visited { COLOR: black; TEXT-DECORATION: none; font-weight: normal }
A:active { COLOR: green; TEXT-DECORATION: none }
A:hover { COLOR: blue; TEXT-DECORATION: none; font-weight: none }
-->
</style>

<?php
include ("nav.php");
include ("database.php");
// include ("echousername.php");
include ("background.php");
// include ("cookieusername.php");
// if ($_COOKIE['ID_my_site'])

	?>

	<br><p>
	<div id="mydiv">
	<style type="text/css">
	DIV { display: none; }
	</style> 

		<Center><b>Additional Details</b>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0"><center>

<Br><p><center><b>Bithrdate
Day:<name="day" />
<select>
<?php
for($iii = 1; $iii <= 31; $iii++)
{
    echo "<option>$iii</option>";
}
?>
</select>

	Month:<name="month" />
	<select>
	<option>January</option>
	<option>Febuary</option
	<option>March</option
	<option>April</option
	<option>May</option
  	<option>June</option
	<option>July</option
	<option>August</option
	<option>September</option
	<option>October</option
	<option>November</option
	<option>December</option
	</select>


Year:<name="year" />
<select>
<?php
for($iii = 1900; $iii <= 2010; $iii++)
{
    echo "<option>$iii</option>";
}
?>
</select><br />



First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" /><br />
<b>Location</b><br />
Location: (eg, country, state, city)<input type="text" name="location" /><br />
<b>Gender</b><br />
<input type="radio" name="gender" value="male" />Male<br />
<input type="radio" name="gender" value="female" />Female<br />
<input type="submit" name="submit" value="submit" />
</form></table>
</div>


<?php

//Checks if there is a login cookie
if(isset($_COOKIE['ID_my_site']))
{
	$username = mysql_real_escape_string( $_COOKIE['ID_my_site'] ); 
	$pass = mysql_real_escape_string( $_COOKIE['Key_my_site'] );

	$check = mysql_query("SELECT * FROM users WHERE username = '$username' AND password = '$pass'")or die(mysql_error());

	while($info = mysql_fetch_array( $check )) 	
	{
		if ($username == $info['username']) 
		echo "$username";
	}
}

	if (isset($_POST['submit'])) { 
$firstname = ($_POST['firstname']);
$lastname = ($_POST['lastname']);
include ("cookieusername.php");

$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
while($info = mysql_fetch_array( $check )) 
$filename = "/home/bob/public_html/mysite/profiles/profileinfo/$username.info.php" or exit("Unable to open file!");
$handle = @fopen($filename, 'x+')or die(mysql_error()); 
$content = "lololo";
@fwrite($handle, $content)or die(mysql_error()); 
@fclose($filename);
}
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
while($info = mysql_fetch_array( $check )) 
include ("/home/bob/public_html/mysite/profiles/profileinfo/$username.info.php")or die(mysql_error()); 
?>

	<br>

<center>
<a href="javascript:;" onmousedown="if(document.getElementById('mydiv').style.display == 'none')
{ document.getElementById('mydiv').style.display = 'block'; }
else{ document.getElementById('mydiv').style.display = 'none'; }">Edit Information.</a> 
</center>

<br>



<br>



	<br>

Link to comment
Share on other sites

Warning: fopen(/home/bob/public_html/mysite/profiles/profileinfo/moo.info.php) [function.fopen]: failed to open stream: File exists in /home/bob/public_html/mysite/profiles/write.php on line 117 

 

ok i changed it to this:

 

 

	if (isset($_POST['submit'])) { 
$firstname = ($_POST['firstname']);
$lastname = ($_POST['lastname']);
include ("cookieusername.php");

$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
while($info = mysql_fetch_array( $check )) 
$filename = "/home/giacjrdi/public_html/mysite/profiles/profileinfo/$username.info.php" or exit("Unable to open file!");
$handle = fopen($filename, 'x+')or die(mysql_error()); 
$content = "lololo";
fwrite($handle, $content)or die(mysql_error()); 
fclose($filename);
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.