SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Insert Into Database With Image Only (Form Needed?)

    Hi,

    I have script which inserts the users ID into a database by using a standard form and submit however. However I am trying to shrink this all down to an image so someone can click an image which inserts the users ID into the database.

    However I am unsure on how to do this. Should I be using a form?


    Code:
    <?php
    
    
    if(isset($_POST['followform'])) {
    
            $follow = $_POST['follow'];
                       
    $query_follow ="UPDATE users SET follow = '".$_POST['follow']."'" ;
    $result_newUser = mysql_query($query_follow);
                    $result = mysql_query($query_follow) or die("An error occurred ".mysql_error());
       
            }
    ?>
    </div> 
    
    
    <form class="followform" method="POST" action="">
    <div class="forminputcell">
    <div class="datainput">
      <div class="forminputleft">
    Follow:
    </div>
      <div class="forminputright">  
    <input   name="follow" type="text" width="10" value="<?php echo $row['id']; ?>" />
    </div>
    </div>
              <div class="user-area">
              <input type="hidden" name="followform" value="submit" />
    <input type="submit" name="submit" value="Submit" class="submit-button" />
      </div>
    </div>
    </form>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    you can, certainly; the <input> tag has a type='image'.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I have it like this but it I cant seem to get it to work. Should the name be follow or followform. I have tried both. Is there something I am missing?


    Code:
     <?php
    
    
     
     if(isset($_POST['followform'])) {
    	
        $follow = $_POST['follow'];
                
    $query_follow ="UPDATE users SET follow = '".$_POST['follow']."'" ;
    $result_newUser = mysql_query($query_follow);
    
            $result = mysql_query($query_follow) or die("An error occurred ".mysql_error());
    
        
        }
    
    ?> 
    	</div> 	
    
    
    
    	<form class="followform" method="POST" action="">
    <div class="forminputcell">
    <div class="datainput">
    		<div class="forminputleft">	
    Follow:
    </div> 
    		<div class="forminputright">			
    <input type="image" img src="/images/logo.png"  name="follow"  value="<?php echo $row['id']; ?>" class="submit-button" />
    </div>
    </div> 
    	</div> 
    </form> 				
    	</div>

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    well the img inside the tag is unnecessary. Take a look at the W3Schools tutorial for the input tag. It should give you an idea of what you need.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    Can you advise any further how I can complete this process?


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
  •