Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Help!!!

  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    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
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is there anything less complex than that?

  • #4
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    It seems to me that the solution I just posted is

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

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #5
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts

    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
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #7
    New Coder
    Join Date
    Jun 2007
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok thanks very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •