Jump to content

legohead6

Members
  • Posts

    434
  • Joined

  • Last visited

    Never

Posts posted by legohead6

  1. everything works...but the last 'if'.... it checks everything and if correct sends off the form to a database!(bolded) please help! also please only rewrite what i should put replacing the bold...(makes it less confusing)

    <html>

    <head>
    <title></title>
    </head>

    <body text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">

    <p align="center"><font face="Aachen-Bold" size="6" color="#FF0000">Splatmen
    Paintball Club</font>
    <p align="center"><font color="#FF0000" face="Comic Sans MS"><a href="http://">Home</a>
    <a href="../Pictures.htm">
    Pictures</a> <a href="members.php">Members</a> <a href="http://www.mattswebpage.com/mainforum/viewforum.php?f=1&sid=4ab3e05eef87dc57e23c7fdf72eb13ab">Forum</a>
    <a href="../Membership.php">
    Player Info</a> <a href="../Chat_Room.htm">Chat room</a>
    <a href="../schedule.htm"> Schedule</a> <a href="../Contact.htm"> Contact</a></font></p>

    <p>
    <?php

    if(isset($_POST['submit']))
    {

    if(!empty($_POST['first'])){
    $first=$_POST['first'];}
    else{
    $name = NULL;
    echo "<p><font color=\"yellow\">*Please enter your First Name!</font></p>";
    }
    if(!empty($_POST['last'])){
    $last=$_POST['last'];
    }else{
    $last = NULL;
    echo "<p><font color=\"yellow\">*Please enter your last Name!</font></p>";}

    if(!empty($_POST['gun'])){
    $gun=$_POST['gun'];
    }else{
    $gun = NULL;
    echo "<p><font color=\"yellow\">*Please enter what kind of gun you have!</font></p>";}

    if(!empty($_POST['age'])){
    $age=$_POST['age'];
    }else{
    $age = NULL;
    echo "<p><font color=\"yellow\">*Please enter how old you are!</font></p>";}

    if(!empty($_POST['saying'])){
    $saying=$_POST['saying'];
    }else{
    $saying = NULL;
    echo "<p><font color=\"yellow\">*Please enter a saying!</font></p>";}

    if(!empty($_POST['email'])){
    $email=$_POST['email'];
    }else{
    $email = NULL;
    echo "<p><font color=\"yellow\">*Please enter your Email Address!</font></p>";}

    if(!empty($_POST['phone'])){
    $phone=$_POST['phone'];
    }else{
    $phone = NULL;
    echo "<p><font color=\"yellow\">*Please enter your Phone Number!</font></p>";}

    if(!empty($_POST['user'])){
    $users=$_POST['user'];
    }else{
    $users = NULL;
    echo "<p><font color=\"yellow\">*Please enter a Username!</font></p>";}

    if(!empty($_POST['pass'])){
    $passs=$_POST['passs'];
    }else{
    $passs = NULL;
    echo "<p><font color=\"yellow\">*Please enter a Password!</font></p>";}
    [b]if ($first && $last && $gun && $age && $saying && $email && $phone && $users && $passs)
    {
    $host = "localhost";
    $user = "--";
    $pass = "--";
    $db = "mattswebpage_com_-_web";

    $connection = mysql_connect($host,$user,$pass) or die ("Unable to
    connect!");

    mysql_select_db($db) or die ("Unable to select database!");

    $query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";
    mysql_query($query);
    }[/b]
    }
    ?>

    <form method="POST" name="membership" action="Membership.php">
    <p align="center">First name <input type="text" name="first" size="20">
    Last Name:<input type="text" name="last" size="24">
    <br><br>
    Phone#<input type="text" name="phone">(format= 000-0000)
    <p align="center">
    Gun type:<input type="text" name="gun" size="36"><br>
    <br>
    Age:<input type="text" name="age" size="3"><br>
    <br>
    Saying:<br>
    <textarea rows="2" name="saying" cols="20"></textarea></p>
    <p align="center">
    Current email address:<input type="text" name="email" size="36">
    </p>
    <p align="center">
    Desired Username:<input type="text" name="user" size="20">
    </p>
    <p align="center">
    Desired pass:<input type="password" name="pass" size="20">
    </p>
    <p align="center">
    </p>
    <p align="center"><input type="submit" value="Submit" name="submit"></p>
    </form>
    </html>
  2. it wont work...heres the code

    [code]Code:

    if($first = NULL
    $last = NULL
    $gun = NULL
    $age = NULL
    $saying = NULL
    $email = NULL
    $phone = NULL
    $users = NULL
    $passs = NULL){
    ......... [/code]


    how do i make it work?
  3. [!--quoteo(post=360614:date=Apr 1 2006, 10:23 AM:name=jeliot)--][div class=\'quotetop\']QUOTE(jeliot @ Apr 1 2006, 10:23 AM) [snapback]360614[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Ok thanks for the info I'm a step closer i think........the query created this error to which I could not figure a solution.

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘ )' at line 1
    [/quote]

    you dont need the ! in your (!isset .... try it without that so "(isset"
  4. how do i stop a form heading to a database from sending untill the user clicks submit? right know it sends whenever they enter or refresh the page! heres the code
    [code] <?php
    $host = "localhost";
    $user = "--";
    $pass = "--";
    $db = "--";

    $first=$_POST['first'];
    $last=$_POST['last'];
    $gun=$_POST['gun'];
    $age=$_POST['age'];
    $saying=$_POST['saying'];
    $email=$_POST['email'];
    $phone=$_POST['phone'];
    $users=$_POST['user'];
    $passs=$_POST['pass'];

    // open connection
    $connection = mysql_connect($host, $user,'$pass') or die ("Unable to
    connect!");

    // select database
    mysql_select_db($db) or die ("Unable to select database!");

    $query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";
    mysql_query($query);
    ?></p>

    <p align="center">Player Info form!</p>
    <form method="POST" name="membership" action="Membership.php">
    <p align="center">First name <input type="text" name="first" size="20">
    Last Name:<input type="text" name="last" size="24">
    <br><br>
    Phone#<input type="text" name="phone">(format= 000-0000)
    <p align="center">
    Gun type:<input type="text" name="gun" size="36"><br>
    <br>
    Age:<input type="text" name="age" size="3"><br>
    <br>
    Saying:<br>
    <textarea rows="2" name="saying" cols="20"></textarea></p>
    <p align="center">
    Current email address:<input type="text" name="email" size="36">
    </p>
    <p align="center">
    Desired Username:<input type="text" name="user" size="20">
    </p>
    <p align="center">
    Desired pass:<input type="password" name="pass" size="20">
    </p>
    <p align="center"><input type="submit" value="Submit" name="B1"></p>
    </form>
    </body>

    </html>
  5. how do i stop a form heading to a database from sending untill the user clicks submit? right know it sends whenever they enter or refresh the page! heres the code
    [code] <?php
    $host = "localhost";
    $user = "--";
    $pass = "--";
    $db = "--";

    $first=$_POST['first'];
    $last=$_POST['last'];
    $gun=$_POST['gun'];
    $age=$_POST['age'];
    $saying=$_POST['saying'];
    $email=$_POST['email'];
    $phone=$_POST['phone'];
    $users=$_POST['user'];
    $passs=$_POST['pass'];

    // open connection
    $connection = mysql_connect($host, $user,'$pass') or die ("Unable to
    connect!");

    // select database
    mysql_select_db($db) or die ("Unable to select database!");

    $query = "INSERT INTO members VALUES ('$first','$last','$gun','$age','$saying','$email','$phone','$users','$passs')";
    mysql_query($query);
    ?></p>

    <p align="center">Player Info form!</p>
    <form method="POST" name="membership" action="Membership.php">
    <p align="center">First name <input type="text" name="first" size="20">
    Last Name:<input type="text" name="last" size="24">
    <br><br>
    Phone#<input type="text" name="phone">(format= 000-0000)
    <p align="center">
    Gun type:<input type="text" name="gun" size="36"><br>
    <br>
    Age:<input type="text" name="age" size="3"><br>
    <br>
    Saying:<br>
    <textarea rows="2" name="saying" cols="20"></textarea></p>
    <p align="center">
    Current email address:<input type="text" name="email" size="36">
     </p>
    <p align="center">
    Desired Username:<input type="text" name="user" size="20">
     </p>
    <p align="center">
    Desired pass:<input type="password" name="pass" size="20">
    </p>
    <p align="center"><input type="submit" value="Submit" name="B1"></p>
    </form>
     </body>

    </html>
  6. [!--quoteo(post=359886:date=Mar 29 2006, 10:49 PM:name=warewolfe)--][div class=\'quotetop\']QUOTE(warewolfe @ Mar 29 2006, 10:49 PM) [snapback]359886[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Hej, try

    <?php
    $link = mysql_connect('localhost', 'user', 'pass);
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully<br>';

    mysql_select_db("test",$link");
    $result = mysql_query(SELECT * FROM people",$link);
    while($row = mysql_fetch_array($result,MYSQL_NUM))
    {
    foreach($row as $val)
    {
    echo'<p>$val</p>';
    }
    }
    ?>
    [/quote]

    parse errors came up.....i dont really know the script so its hard for me to try to correct....

    [!--quoteo(post=359890:date=Mar 29 2006, 11:00 PM:name=sambib)--][div class=\'quotetop\']QUOTE(sambib @ Mar 29 2006, 11:00 PM) [snapback]359890[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    [code]<?php
    {
        //attempt to connect to the database server
        //if the attempt was successful
        if (@mysql_connect('localhost', 'user', 'pass))) {
        
            //attempt to select the mycms databse
            //if the attempt was successful
            if (@mysql_select_db("test")) {
        
            //return true
            return TRUE;
            
            //Or if the selection was unsuccessful
            } else {
            
                //display error message
                echo "<p>Unable to select the database .</p>";
                
                //Return False
                return FALSE;
            }
            
        } else {
        
            //Display the error message
            echo "<p>Unable to connect to the database server</p>";
        
            //return false
            return FALSE;
        }
    }

    $query = "SELECT * FROM people"; //put some other criteria in to refine your query
    $result = mysql_query ($query);

    // check to see how many rows we have. if we have 0 rows then nothing has returned
    if(mysql_num_rows($result) < 1) {

        echo('<p>the is no data in the table!</p>');

    } else {
            
             //run through the results of the query and put the result into an array called $row
        while ($row = mysql_fetch_assoc($result)) {

    ?>//stop the while loop and display the records

    <p>here are the details of the field name<?= $row['fieldName'] ?></p> <!--change field name and fieldName for the correct names of the table fields. -->

    <?php
        
    } //end the while loop

    ?> [/code]

    that should get you started
    [/quote]

    wow....umm this came up

    Parse error: parse error, unexpected T_STRING in /var/www/html/PHP/data.php on line 42

    [!--quoteo(post=359887:date=Mar 29 2006, 10:49 PM:name=toplay)--][div class=\'quotetop\']QUOTE(toplay @ Mar 29 2006, 10:49 PM) [snapback]359887[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Please be more specific of what you need help with as it relates to databases. For basic connect, select, and fetch see tutorials and code example at the FAQ page link bellow. Look for my post there related to MySQL data retrieval.

    [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=31047[/a]
    [/quote]

    Thanks i found the stuff...but how do i set up a query..(im new to databases and php)
  7. ok so far heres my script

    <?php
    $link = mysql_connect('localhost', 'user', 'pass);
    if (!$link) {
    die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully<br>';
    ?>


    know i want it to display information from the database "test" on table "people" please help me with the code!
×
×
  • 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.