SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 54
  1. #26
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    look if u have done that code already then just take a backup 1st , after that remove and just use session_start() on every page i.e. page1 , page 2 and so on
    and keep values in session vaiables like u said before
    session_start();
    $_SESSION['name'] = $_POST['name'];
    keep session start on everypage means , write down only on those pages where u r accessing sesionn varables
    if u r not doing any operation on page2 with thses varables then just dont use session_start(). use where u required session var.

  2. #27
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Losse
    Another question...

    On page 4 - the confirmation page, I bring up all the fields the user input in the first 3 pages with a SELECT quiery... Since there won't be anything in the DB to "SELECT" from, how would I display those fields on the confirmation page?
    u r using both DB and session ?

    u said u r only using session now u r asking for DB.

    what r u doing plz be clear about it.

  3. #28
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple Code... Here are you answers... Thanks for your paitence!

    Right now I have a DB.
    -On page 1 of the registration form I have an INSERT script
    -On page 2 I have an UPDATE
    -On page 3 I have an UPDATE
    -On page 4 (the confirmation page) I have a SELECT script.

    The reason I am here is because I found that this won't work if the user goes back and tries to fix a mistake they might have made.

    So I'm trying to find a way to have these 3 pages of registration, the final confirmaton page and a "solution" that would allow the user to go back and make changes it needed... once they've made their changes, submit the data to the DB

    Right now I'm open for anything... If it means re-writing the code, I'm game... I just want to know how I can create this solution.

    Thanks again

  4. #29
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u r doing the right thing am not understanding why this is not working still i'll try 2 explain:
    Assumptions
    Step 1 Reggistration Page 1 Contains : Fname , Lname , Email
    Step 2 Reggistration Page 2 Contains : City , State , Country
    Step 3 Reggistration Page 3 Contains : Subscription , Free Trial
    Step 4 Reggistration Page 4 Contains : Confirmation Yes/No

    > Go for DB option
    > after page 1 when ur control comes on second page just keep data of page 1 into db with all fileds i.e insert Fname , Lname , Email into DB
    --- $user_id = mysql_insert_id(); then use this command to caught the last inserted id to work on the same record
    > after filling up the 2nd reg form when control comes on 3rd reg form just update same record whose id = $user_id and update fileds
    City , State , Country in same table
    > after filling up 3rd do the same ...update record whose id = $user_id and update fileds Subscription , Free Trial
    > when ur control comes to 4th form ur all fileds are in db (Fname , Lname , Email, City , State , Country,Subscription , Free Trial)
    and u have $user_id now if user wants to go back to 3rd form or any form by back then as per the form just fill the form fileds from
    db using the $user_id(select * from table where id=$user_id) and if he updates the same then use update query for ths same.

    r u getting what is happening here ?
    i hope m not doing any mistake
    sorry 4 poor english

  5. #30
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple cdoe... Thanks for your reply... By the way are you on MSN ? Could we chat about this?

    I understand everything up until

    ...if user wants to go back to 3rd form or any form by back then as per the form just fill the form fileds from
    db using the $user_id(select * from table where id=$user_id) and if he updates the same then use update query for ths same.
    Say the user goes to the confirmation page 4 and sees that he mispelled Fname... So he hits the "back" button to page 1, updates the Fname then clicks on next....

    When he hits next, as you mentioned, wouldn't htat be a second INSERT? Therefore creating an additioanl user ID?

    I'm on MSN at carlos_omis@hotmail.com

  6. #31
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Losse
    Say the user goes to the confirmation page 4 and sees that he mispelled Fname... So he hits the "back" button to page 1, updates the Fname then clicks on next....

    When he hits next, as you mentioned, wouldn't htat be a second INSERT? Therefore creating an additioanl user ID?

    [/email]
    when updates the Fname then clicks on next....
    again u have to fire update quey for same userid

  7. #32
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dont insert as u have thoses record in db already u just have to update thos records by using $user_id
    i dont have msn sory

  8. #33
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how do you insert (on page 1) and then update (on page 1) assuming he goes back?

    Do you do something like, INSERT if the user doesn't exist and if the user exists look for the ID and UPDATE?

  9. #34
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you do something like, INSERT if the user doesn't exist and if the user exists look for the ID and UPDATE?
    1st time after page 1 use INSERT

    if($user_id !="")
    INsert
    else
    update

  10. #35
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    something like this

    PHP Code:
    session_start();
    if(
    $_SESSION['userid_id'] != "")
    {
        
    $sqlinsert "Insert into tabl (fname,lname) values('$fname','$lname') ";
            
            if(!(
    mysql_query($sqlinsert)))    
            {
                echo 
    "1--".$sqlinsert.mysql_error();
                exit;
            }
            
    $userid_id=mysql_insert_id();
            
    $_SESSION['userid_id'] = $userid_id;
    }
    else
    {
        
    $sqlupdate "update tabl set fname ='$fname' where tableid  = $userid_id";


  11. #36
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when next time user visits this page $_SESSION['userid_id'] it wont be empty and it will directly updates the record by accessing else part of query

  12. #37
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i hope am not doing any mistak in this

  13. #38
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds good. Let me look this over and give it a whirl! Thanks for your time.. I'll check back with the results.

  14. #39
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way I understand everything in that script except for this...

    Care to explain?

    PHP Code:
    echo "1--".$sqlinsert.mysql_error(); 
                exit; 
    thanks I appreciate it.

  15. #40
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Losse
    By the way I understand everything in that script except for this...

    Care to explain?

    PHP Code:
    echo "1--".$sqlinsert.mysql_error(); 
                exit; 
    thanks I appreciate it.

    Thatís nothing but the check for err.
    if in any case ur query fails coz of syntax or anything then it will simply throws an err with the query
    1-- is nothing it simply a no. i prefer it 2 find out when there r no. of queries.

  16. #41
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    allright I think we're getting somewhere...

    I got this error after I hit submit on page 1: Error in query: . Query was empty

    Here's the code for the entire page 1.

    PHP Code:
    <?php  
    ob_start
    (); // Send the output.  
    session_start(); 
    ?> 
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>ID Alerts - Registration Page 1</title>
    </head>

    <body>
    <table width="748
    " border="0" align="center">
      <tr>
        <td colspan="2"><img src="temp_header.jpg" width="748" height="112" /></td>
      </tr>
      <tr>
        <td width="26%"><img src="temp_side.jpg" width="196" height="661" /></td>
        <td width="74%">                        
        

        <table cellspacing="2" cellpadding="2" border="0" width="520">
    <?php 
    if (!isset($_POST['submit'])) { 
    // form not submitted 
    ?> 
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 
                                    <tr>
                                        <td colspan="2" valign="bottom" align="right"><img src="../images/register1.gif" width="370" height="40" border="0" /></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" bgcolor="#dadada"><p><b>Please Select a Product</b>:</p></td>
                                    </tr>
                                    <tr>
                                        <td width="230" align="right">
                                            <p>T.I.P.S Elite Bundle</p>                                    </td>
                                        <td>
                                            <p><input type="radio" value="Elite Bundle" name="product" >$22.25 Monthly (<a href="http://www.idalerts.ca/products/pricing.html" target="_blank">Full pricing details</a>)</p>                                    </td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#dadada" colspan="2">
                                            <p><b>Please Select a </b><b>Additional Service</b>:</p>                                    </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" bgcolor="#dadada"><p><b>Identification Information </b><font color="#cc0000"> (*-Required Information)</font>:</p>                                    </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            <p>First Name<font color="#cc0000">*</font>:</p>                                    </td>
                                        <td><input type="text" name="name" size="45" tabindex="1" value= ""></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" bgcolor="#dadada">
                                            <p><b>Mailing Address</b><font color="#cc0000"> (*-Required Information)</font>:</p>                                    </td>
                                    </tr>
                                    <tr>
                                        <td align="right"></td>
                                        <td><p>1&nbsp;of&nbsp;4&nbsp;<font size="2" face="Trebuchet MS,Arial,Helvetica"><input type="submit" name="submit" value="Next"></font></p>                                    </td>
                                    </tr>
                                </form>
    <?php 

    else { 
    // form submitted 
    // set server access variables 
        
    $host "xxx"
        
    $user "xxx"
        
    $pass "xxx"
        
    $db "xxx"
    // get form input 
        // check to make sure it's all there 
        // escape input values for greater safety 
        
    $product = empty($_POST['product']) ? die ("ERROR: Please enter the product you wish to have") : mysql_escape_string($_POST['product']); 
        
    $name = empty($_POST['name']) ? die ("ERROR: Please enter your first name") : mysql_escape_string($_POST['name']); 

        
    // 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!"); 

    //Create quiery
    if($_SESSION['userid_id'] != ""

        
    $sqlinsert "Insert into client (product, name) values('$product', '$name')"
             
            if(!(
    mysql_query($sqlinsert)))     
            { 
                echo 
    "1--".$sqlinsert.mysql_error(); 
                exit; 
            } 
            
    $userid_id=mysql_insert_id(); 
            
    $_SESSION['userid_id'] = $userid_id

    else 

        
    $sqlupdate "UPDATE client SET product='$product', name='$name' WHERE ID = $userid_id"

        
        
    // execute query 
        
    $result mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
        
        
    // Grab ID for the inserts on the next page
        
    $_SESSION['userid_id'] = mysql_insert_id(); 
         
        
    // redirect
        
    header("Location: http://www.xxx.com/register2b.php");
        
    ob_end_flush(); 
         
        
    // close connection 
        
    mysql_close($connection); 

    ?> 
                            </table></td>
      </tr>
    </table>
    </body>
    </html>

  17. #42
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    else 

        
    $sqlupdate "UPDATE client SET product='$product', name='$name' WHERE ID = $userid_id"

         
        
    // execute query 
        
    $result mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
    proble is here

    PHP Code:
    $result mysql_query($query) -- > make it $result mysql_query($sqlupdate 

  18. #43
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks... Good eye!!
    Here's another error now!?

    Error in query: . 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

  19. #44
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on which query u have this err

  20. #45
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I submit page 1...

  21. #46
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i mean on insert quer or on update query

  22. #47
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    print the query

  23. #48
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use this and try

    PHP Code:
    else 

        
    $sqlupdate "UPDATE client SET product='$product', name='$name' WHERE ID = $userid_id"
        if(!(
    mysql_query($sqlupdate)))      
        { 
            echo 
    "2--".$sqlupdate.mysql_error(); 
            exit; 
        } 


  24. #49
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is ur db connection is ok

  25. #50
    SitePoint Addict
    Join Date
    Dec 2004
    Location
    canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah... the DB connection is ok...

    I think the error is on the update...

    Here's the error:

    2--UPDATE client SET product='Elite Bundle', name='ddddd' WHERE ID = 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


Bookmarks

Posting Permissions

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