help

xsystemx

New Member
Messages
4
Reaction score
0
Points
0
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>FOFDB</title>
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include("./div/logo.php"); ?>
<?php include("./div/menu.php"); ?>
<div id="wrapper">
<?php include("./div/col-one.php"); ?>
<div id="col-two">
<div class="boxed">
<h2 class="title">SUBMIT</h2>
<div class="content">
<p>
<?php 
$A = $_POST['Artist']; 
$B = $_POST['Album']; 
$C = $_POST['Song'];
$D = $_POST['GuitarX'];
$E = $_POST['GuitarH'];
$F = $_POST['GuitarM'];
$G = $_POST['GuitarE'];
$H = $_POST['BassX'];
$I = $_POST['BassH'];
$J = $_POST['BassM'];
$K = $_POST['BassE'];
$L = $_POST['DrumsX'];
$M = $_POST['DrumsH'];
$N = $_POST['DrumsM'];
$O = $_POST['DrumsE'];
$P = $_POST['Download'];
$sqlQuery1 = "SELECT * FROM `ARTIST` WHERE `ARTIST` = '$A' LIMIT 0 , 1";
$sqlQuery2 = "SELECT * FROM `ALBUM` WHERE `ARTIST` = '$A' AND `ALBUM` = '$B' LIMIT 0 , 1";
$sqlQuery3 = "INSERT INTO `ARTIST` (`id` ,`ARTIST`) VALUES (NULL , '$A');";
$sqlQuery4 = "INSERT INTO `ALBUM` (`ID` ,`ARTIST` ,`ALBUM` ,`YEAR` ,`ART` ) VALUES (NULL , '$A', '$B', '', '');";
$sqlQuery5 = "INSERT INTO `SONG` (`ID` ,`ARTIST` ,`ALBUM` ,`SONG` ,`DISC` ,`TIME` ,`TRACK` ,`CAREER` ,`TIER` ,`DOWNLOAD` ,`GX` ,`GH` ,`GM` ,`GE` ,`BX` ,`BH` ,`BM` ,`BE` ,`DX` ,`DH` ,`DM` ,`DE` )VALUES (NULL , '$A', '$B', '$C', 'NULL', 'NULL', 'NULL', NULL , NULL , '$P', '$D', '$E', '$F', '$G', '$H', '$I', '$J', '$K', '$L', '$M', '$N', '$O');"; 
mysql_connect("") or die(mysql_error());
mysql_select_db("xsystemx_songs") or die(mysql_error());
if $A == $sqlQuery1 then echo "VALID ARTIST" else $sqlQuery3 will run
if $B == $sqlQuery2 then echo "VALID ALBUM" else $sqlQuery4 will run
$sqlQuery5 runs no matter what
What would i have to do to pull that off?
PHP:
?>
</p>
</div>
</div>
</div>
<?php include("./div/col-three.php"); ?>
</div>
<?php include("./div/footer.php"); ?>
</body>
</html>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Your subject line is terrible. You'll probably get more help in the future if you write better ones.

PHP:
<div id="wrapper">
<?php include("./div/col-one.php"); ?>
<div id="col-two">
<div class="boxed">
<h2 class="title">SUBMIT</h2>
<div class="content">
<p>
<?php 
$A = $_POST['Artist']; 
$B = $_POST['Album']; 
$C = $_POST['Song'];
...
Yay! You've given your included scripts more descriptive names. You still need to do the same for your variables. You're also still not filtering the user input.

Any time you find yourself repeatedly typing very similar lines in sequence, use a loop.

PHP:
mysql_connect("") or die(mysql_error());
mysql_select_db("xsystemx_songs") or die(mysql_error());
Rather than die()ing, use an if statement. die() will prevent the rest of your page (including footers) from being sent.
if $A == $sqlQuery1 then echo "VALID ARTIST" else $sqlQuery3 will run
if $B == $sqlQuery2 then echo "VALID ALBUM" else $sqlQuery4 will run
$sqlQuery5 runs no matter what
What would i have to do to pull that off?
You're almost there. Rather than testing if $A is equal to anything returned by $sqlQuery1, test if the query returned no rows. If so, run $sqlQuery3. Do similar for $B/$sqlQuery2/$sqlQuery4. You might also want to give the queries more descriptive names, such as $lookForArtistQuery and $insertArtistQuery.
 
Top