Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2007, 12:42 AM   PM User | #1
newline
New Coder

 
Join Date: Jun 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
newline is an unknown quantity at this point
Help!!!

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
newline is offline   Reply With Quote
Old 06-01-2007, 12:51 AM   PM User | #2
whizard
Senior Coder

 
whizard's Avatar
 
Join Date: Jan 2005
Location: Philadelphia, PA, USA
Posts: 1,457
Thanks: 10
Thanked 37 Times in 37 Posts
whizard will become famous soon enoughwhizard will become famous soon enough
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:
PHP Code:
$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
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
whizard is offline   Reply With Quote
Old 06-01-2007, 02:33 AM   PM User | #3
newline
New Coder

 
Join Date: Jun 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
newline is an unknown quantity at this point
is there anything less complex than that?
newline is offline   Reply With Quote
Old 06-01-2007, 03:22 AM   PM User | #4
whizard
Senior Coder

 
whizard's Avatar
 
Join Date: Jan 2005
Location: Philadelphia, PA, USA
Posts: 1,457
Thanks: 10
Thanked 37 Times in 37 Posts
whizard will become famous soon enoughwhizard will become famous soon enough
It seems to me that the solution I just posted is

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

Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
whizard is offline   Reply With Quote
Old 06-01-2007, 04:08 AM   PM User | #5
newline
New Coder

 
Join Date: Jun 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
newline is an unknown quantity at this point
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?
newline is offline   Reply With Quote
Old 06-01-2007, 10:37 AM   PM User | #6
whizard
Senior Coder

 
whizard's Avatar
 
Join Date: Jan 2005
Location: Philadelphia, PA, USA
Posts: 1,457
Thanks: 10
Thanked 37 Times in 37 Posts
whizard will become famous soon enoughwhizard will become famous soon enough
Post

Code:
<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
PHP Code:
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
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
whizard is offline   Reply With Quote
Old 06-01-2007, 10:59 PM   PM User | #7
newline
New Coder

 
Join Date: Jun 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
newline is an unknown quantity at this point
ok thanks very much!
newline is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:33 PM.


Advertisement
Log in to turn off these ads.