Jump to content

Recommended Posts

Hello,

I am new to PHP and MySql, and need guidance in extracting content from database, i have created two file for uploading the data the file structure and database structure is as below

 

File1 (Main file to upload content)

 

<script language="JavaScript">
function validation()
{
  if(document.productaddform.title.value=="")
  {
  alert("Title Field is empty!");
  document.productaddform.title.focus();
  return false;   
  }
  if(document.productaddform.dllink.value=="")
  { 
  alert("Please Enter correct Download Link");
  document.productaddform.dllink.focus(); 
  return false; 
  } 
  var ch=document.productaddform.dllink.value;
  if(ch.length<6)
  { 
  alert("Download Link should be minimum 6(Six) characters"); 
  document.productaddform.dllink.value="";
  document.productaddform.dllink1.value="";
  document.productaddform.dllink.focus();
  return false; 
  } 
  if(document.productaddform.dllink.value!=document.productaddform.dllink1.value)
  { 
  alert("Download Link miss match, Please Make sure the entered URL is Correct"); 
  document.productaddform.dllink1.focus();
  return false; 
  } 
  if(document.productaddform.imgurl.value=="")
  { 
  alert("Please Enter Image URL"); 
  document.productaddform.imgurl.focus();
  return false; 
  } 
  if(document.productaddform.price.value=="")
  { 
  alert("Please Enter correct Price"); 
  document.productaddform.price.focus();
  return false; 
  } 
  if(document.productaddform.pr.value=="")
  { 
  alert("Please select correct Product Rights."); 
  document.productaddform.pr.focus();
  return false; 
  } 
}
function checkCapsLock(e) 
{
  var myKeyCode=0;
  var myShiftKey=false;
  var myMsg='Caps Lock is On.\n\nTo prevent entering your URL incorrectly,\nyou should press Caps Lock to turn it off.';
  myKeyCode=e.keyCode;
  if ( document.all ) 
  {
  myKeyCode=e.keyCode;
  myShiftKey=e.shiftKey;
  }
  else if ( document.layers ) 
  {
  myKeyCode=e.which;
  myShiftKey=( myKeyCode == 16 ) ? true : false;
  } else if ( document.getElementById ) 
  {
  myKeyCode=e.which;
  myShiftKey=( myKeyCode == 16 ) ? true : false;
  }
  if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) 
  {
  alert( myMsg );
  } else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) 
  {
  alert( myMsg );
  }
}
</script>
<?php  
include("../config.php");
include("head.php"); 

?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <form action="addproductdb.php" method="post" name="productaddform" onSubmit="return validation();">
                <tr>
                  <td height="50" colspan="2"><p>Add Product <font size="4" face="Georgia, Times New Roman, Times, serif"> </font>(<font color="#FF0000">* </font>denotes Compulsary field)<br>
                      <font size="2">
                      <?php 
if(isset($_GET['opt']))
{
echo "<br>";
if($_GET['opt']==1) echo "<strong>This Title already exists, Try again with Different Title</strong> ";
}
?>
                      </font></p></td>
                </tr>
                <tr>
                  <td height="24"> </td>
                  <td height="24"> </td>
                </tr>
                <tr>
                  <td height="24">Tiltle:<font class="bodyFont"> <font color="#FF0000">*</font></font></td>
                  <td height="24"><input name="title" type="text" id="title" size="40"></td>
                </tr>
                <tr>
                  <td height="24"><font class="bodyFont">Download Link<font color="#FF0000">*</font></td>
                  <td height="24"><input name="dllink" type="text" id="dllink" size="40" onKeyPress="checkCapsLock(event);">
                    (Minimum 6 chars)</td>
                </tr>
                <tr>
                  <td height="24"><font class="bodyFont">Download Link<font color="#FF0000">*</font></td>
                  <td height="24"><input name="dllink1" type="text" id="dllink1" size="40" onKeyPress="checkCapsLock(event);"></td>
                </tr>
                <tr>
                  <td width="21%" height="24"><div align="left"><font class="bodyFont">Image URL <font color="#FF0000">*</font></div></td>
                  <td width="79%" height="24"><input name="imgurl" type="text" id="imgurl" size="40"></td>
                </tr>
                <tr>
                  <td height="24"><div align="left">Price: <font color="#FF0000">*</font></div></td>
                  <td height="24"><input name="price" type="text" id="price" size="40"></td>
                </tr>
                <tr>
                  <td height="168"><div align="left">Description:</div></td>
                  <td height="168"><script language="JavaScript1.2" defer>
      editor_generate('message');
      </script>
                    <textarea name="description" cols="60" rows="10" id="description"></textarea></td>
                </tr>
                <tr>
                  <td height="24">Product Rights:<font class="bodyFont"> <font color="#FF0000">*</font></td>
                  <td height="24"><SELECT name=pr size=1 id="pr" >
                      <option value="GAR" selected="selected">Give Away Rights</option>
                      <option value="RR">Resale Rights</option>
                      <option value="MRR">Master Resale Rights</option>
                      <option value="PLR">Private Label Rights</option>
                    </SELECT></td>
                </tr>
                <tr>
                  <td height="24"><div align="left"></div></td>
                  <td height="24"> </td>
                </tr>
                <tr>
                  <td height="24"> </td>
                  <td height="24"><input name="Submit" type="submit" value="Submit and Proceed"></td>
                </tr>
              </form>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<?php  include("foot.php"); ?>

 

 

File2 (Add the same to database)

 

 

<?php 
include("../config.php");
$dq1 = mysql_query("SELECT * FROM affiliate_product WHERE title='".$_POST['title'] . "'") or die(mysql_error());
$count=mysql_num_rows($dq1);
if(mysql_num_rows($dq1)> 0)
{
    echo '<script> window.location="productadd.php?opt=1";</script>';
}
else
{
$refId="";
  mysql_query("INSERT INTO `affiliate_product` values ('','".$_POST['title']."','".$_POST['dlink']."','$refId',
  '".$_POST['imgurl']."','".$_POST['price']."','".$_POST['description']."','".$_POST['pr']."''')")
   or die(mysql_error());
  $pid=mysql_insert_id();
  echo '<script>window.location="addsuccess.php?id='.$pid.'";</script>';
}
?>

 

SQL Structure

 

--

-- Table structure for table `affiliate_product`

--

CREATE TABLE `affiliate_product` (

  `productId` int(10) NOT NULL auto_increment,

  `title` varchar(200) NOT NULL default '',

  `dllink` varchar(200) NOT NULL default '',

  `refId` int(20) NOT NULL default '0',

  `imgurl` varchar(200) NOT NULL default '',

  `price` varchar(200) NOT NULL default '',

  `description` text NOT NULL,

  `pr` varchar(100) NOT NULL default '',

  PRIMARY KEY  (`productId`)

)   AUTO_INCREMENT=1 ;

--

-- Dumping data for table `affiliate_product`

--

-- --------------------------------------------------------

 

 

 

Need Guidance in following points

1) How do i extract the content and images

2) Is there any way by which i can confirm that the user is registered member before he can download the product by clicking on download link?

3) if i have added say 200 products, how can i display 25 products per page, and the number of pages will increase automatically when more products are added.

Please Correct my code if there is any error,

Thanxs in advance,

Best Regards,

Ritesh Jain

  • 2 months later...

Hey

 

You can use select statements to get information from the database and display it in tables or DIVs or frames using echo and print statements, as you may wish!

 

Yes, you can use sessions in your login to check if someone is logged in before performing any action!

 

AND YES, YOU CAN DISPLAY A PARTICULAR NO OF PAGES using php PAGINATION

 

There are alot of tutorials on all the above

 

Get back if stuck..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.