Email Collection to MYSQL

Discussion in 'PHP' started by aaron_nimocks, Sep 28, 2006.

  1. #1
    I cant find this anywhere.

    All I need is a form to collect email address and name and store it in a txt file or mysql.

    Does anyone know where I can get this?
     
    aaron_nimocks, Sep 28, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mad4, Sep 28, 2006 IP
  3. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #3
    Ya that looks like more than I need.

    Just need name and email and store it somewhere. Can you show me an example of that?
     
    aaron_nimocks, Sep 28, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <?php
    
    include('dbconnect.inc.php');
    $author = $_POST["author"];
    $email = $_POST["email"];
    $author=mysql_escape_string($author);
    $email=mysql_escape_string($email);
    if($email==""){
    ?>
    <form>
    Email<input type="text" name="email">
    Name<input type="text" name="author">
    </form>
    <?php
    		}
    		else
    		{
    			
    	$SQLcommand = "INSERT INTO yourtable";	
    	$SQLcommand = "$SQLcommand (name,email) ";
    	$SQLcommand = "$SQLcommand VALUES(";
    	$SQLcommand = "$SQLcommand '$author','$email') ";
    	MYSQL_QUERY($SQLcommand);
    	
    echo"Thanks";
    		}
    ?>
    PHP:
     
    mad4, Sep 28, 2006 IP
    aaron_nimocks likes this.
  5. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #5
    Im have very little experience at this.

    Would the only thing I need to change to make this work is to make a dbconnect.inc.php file?

    Those SQLcommand lines look fishy to me.
     
    aaron_nimocks, Sep 28, 2006 IP
  6. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The sqlcommands are copied from one of my email collection scripts.:)
    This is the dbconnect file:
    
    $mainconnection =MYSQL_CONNECT("localhost","user","pass") OR DIE("Unable to connect to database");  
    
    @mysql_select_db("yourdbname") or die("Unable to select database");
    
    PHP:
     
    mad4, Sep 28, 2006 IP
  7. aaron_nimocks

    aaron_nimocks Im kind of a big deal Staff

    Messages:
    5,563
    Likes Received:
    627
    Best Answers:
    0
    Trophy Points:
    420
    #7
    Got it and its working.

    Thanks :)
     
    aaron_nimocks, Sep 28, 2006 IP