...

View Full Version : Help!!!



newline
06-01-2007, 12:42 AM
Hey,
Im in the process of making a small upload script. In the admin panel I want there to be a form where I can put my email in and it sets my email to a config.php page.


Ok im going to need a form in which the user puts there main email in, then the email needs to be stored in a config.php page.


Now on the contact form ill have to include(config.php then have a variable like $emailaddy in config.php which will be under the contact page.


Sounds complex!! Please help me out



Basically I want a form where the admin puts there emails in, then have that information put into a variable so I can use it in the contact form

whizard
06-01-2007, 12:51 AM
I don't think you can do that exactly how you are suggesting.

If you want to save a variable in a file, you're going to have to open the file, and go line by line until you get to the line which has your variable. I don't think that's what you want to do.

You might want to do something more like this, storing the email address in a file specifically for that purpose:


$email = $_POST['email'];

$fh = fopen("includes/email.php","w");
fwrite($fh,"\$email=$email");
fclose($fh);


Then you could include includes/email.php (instead of config.php) to get your email address.

Of course, you're going to want to make sure that no one else can submit the form.

I don't know how secure this is, so if anyone sees any issues with it, please point them out...

HTH
Dan

newline
06-01-2007, 02:33 AM
is there anything less complex than that?

whizard
06-01-2007, 03:22 AM
It seems to me that the solution I just posted is

a) simple
b) much simpler than the one which you had proposed

Dan

newline
06-01-2007, 04:08 AM
Alright, but Can I use a form so a person could insert there email and submit it, and it would add it into that variable?

whizard
06-01-2007, 10:37 AM
<form action="storevalue.php" method="post">
Enter your email address below:
<br />
<input name="email" type="text" />
<input name="submit" type="submit" value="Save Email" />
</form>


storevalue.php


if(!empty($_POST['submit']))
{
$email = htmlspecialchars($_POST['email']);
$fh = fopen("includes/email.php","w");
fwrite($fh,"\$email=$email");
fclose($fh);
//Go to the home page
header("Location: index.php");
}
else
{
//If the file is accessed by its URL, and not by a form submission
header("Location: index.php");
}


Like I said earlier, you want to be sure you are the only one who has access to the form.

Dan

newline
06-01-2007, 10:59 PM
ok thanks very much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum