Jump to content

Submit = blank Page


haris244808

Recommended Posts

Hi there.

When i press the submit button it shows me the blank page. Do u have any idea why? (i tried also to show me errors but it doesnt show even errors, although the display erorr works well)

I want to send the user inputs and chosens to the database: (table form contains all the fields required (type, price, picture, gear,condition...etc))

 

 

 

here is the html page:

[m]<body>

<div id="wrapper" class="container_12 clearfix">

	<!-- Text Logo -->
	<h1 id="logo" class="grid_4"></h1>

	<!-- Navigation Menu -->
	<ul id="navigation" class="grid_8">
		<li><a href="contact.php"><span class="meta">Get in touch</span><br />Contact Us</a></li>
		<li><a href="blog.php"><span class="meta">Latest news</span><br />Blog</a></li>
		<li><a href="portfolio.php"><span class="meta">Our latest work</span><br />Portfolio</a></li>
		<li><a href="about.php" class="current"><span class="meta">Who are we?</span><br />About</a></li>
		<li><a href="index.php"><span class="meta">Homepage</span><br />Home</a></li>
	</ul>

        	<div class="hr grid_12 clearfix"> </div>

	<!-- Caption Line -->
	<h2 class="grid_12 caption">Complete the <span>Admin Form</span> </h2>

	<div class="hr grid_12 clearfix"> </div>
        
	<div>
        <div class="grid_12 caption">
          <form action="adminFormSubmit.php" method="get" enctype="multipart/form-data" name="adminForm">
          <table width="100%" border="0" align="center">
            <tr>
              <th scope="row"><div align="right">Type</div></th>
              <td><div align="center">
                <input type="text" name="type" id="type" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Year</div></th>
              <td><div align="center">
                <input type="text" name="year" id="year" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Gear</div></th>
              <td><div align="center">
                <select name="gear" id="gear">
                  <option value="M">Manual</option>
                  <option value="A" selected="selected">Automatic</option>
                </select>
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Condition</div></th>
              <td><div align="center">
                <select name="condition" id="condition">
                  <option value="N" selected="selected">New</option>
                  <option value="U">Used</option>
                </select>
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Km's Past</div></th>
              <td><div align="center">
                <input type="text" name="km" id="km" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Price</div></th>
              <td><div align="center">
                <input type="text" name="price" id="price" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right">Picture</div></th>
              <td><div align="center">
                <input type="file" name="picture" id="picture" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"> </th>
              <td><div align="center">
                <input class="button" type="submit" name="adminFormSubmit" id="adminFormSubmit" value="Submit" />
              </div></td>
            </tr>
            <tr>
              <th scope="row"><div align="right"></div></th>
              <td><p align="right"><a class="button" href="logout.php">Log out</a></p></td>
            </tr>
          </table>
          </form>
        </div>
        </div>

<div class="hr grid_12 clearfix"> </div> 
    
	<!-- Footer -->
		<p class="grid_12 footer clearfix">
		<span class="float"><b>EpokaUniversity || All Rights Reserved © Copyright</b> || HarisKrasniqi, DiamantNeziri, HarisMemeti, KelmendTairi.</span>
		<a class="float right button" href="#">top</a>
	</p>

</div><!--end wrapper-->

</body>[/m]

 

 

 

and here is the php code:

 

[m]<?php

//check if the button is pressed
if(isset($_POST['adminFormSubmit'])){

//Connect to database
require_once('Connections/ecommerce_dbcon.php'); 

// Check to see if the type of file uploaded is a valid image type
function is_valid_type($file)
{
	// This is an array that holds all the valid image MIME types
	$valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/png");

	if (in_array($file['type'], $valid_types))
		return 1;
	    return 0;
}
// This variable is the path to the image folder where all the images are going to be stored
// Note that there is a trailing forward slash
$TARGET_PATH = "adminform_images/";

// Get our POSTed variables
$type = $_POST['type'];
$year = $_POST['year'];
$gear = $_POST['gear'];
$condition = $_POST['condition'];
$km = $_POST['km'];
$price = $_POST['price'];
$picture = $_FILES['picture'];


// Sanitize our inputs
$type = mysql_real_escape_string($type);
$year = mysql_real_escape_string($year);
$gear = mysql_real_escape_string($gear);
$condition = mysql_real_escape_string($condition);
$km = mysql_real_escape_string($km);
$price = mysql_real_escape_string($price);
$picture['name'] = mysql_real_escape_string($picture['name']);


// Build our target path full string.  This is where the file will be moved do
// i.e.  images/picture.jpg
$TARGET_PATH .= $picture['name'];

// Make sure all the fields from the form have inputs
if ( $type == "" || $year == "" || $gear == "" || $condition == ""  || $km == "" || $price == ""|| $picture['name'] == "" )
{
	echo "Te gjithe fushat duhet plotesuar. <a href=adminsection.php>Provo perseri</a>";
	exit;
}

// Check to make sure that our file is actually an image
// You check the file type instead of the extension because the extension can easily be faked
if (!is_valid_type($picture))
	{
	echo "Fotografite duhet te jene te formateve jpg, jpeg, bmp, gif, ose png. <a href=adminsection.php>Kthehu prapa</a>";
	exit;
}

// Here we check to see if a file with that name already exists
// You could get past filename problems by appending a timestamp to the filename and then continuing
if (file_exists($TARGET_PATH))
{
	echo "Ju lutem nderroni emrin e fotos dhe provoni perseri. <a href=adminsection.php>Kthehu prapa</a>";
	exit;
}

	// Lets attempt to move the file from its temporary directory to its new home
if (move_uploaded_file($picture['tmp_name'], $TARGET_PATH))
{
	// NOTE: This is where a lot of people make mistakes.
	// We are *not* putting the image into the database; we are putting a reference to the file's location on the server
	$sql = "INSERT INTO form (type, year, gear, condition, km, price, picture, date_added,) values ('$type', '$year', '$gear', '$condition', '$km', '$price', '" . $image['name'] . "',  now(),)";
	$result = mysql_query($sql) or die ("Futja e te dhenave ne databaze DESHTOI. <a href=adminsection.php>Provo perseri</a> ");
	echo "Shtimi i te dhenave u krye me SUKSES. Klikoni per te shkuar tek <a href=index.php>faqja kryesore</a>";
	exit;
}
else
{
	// A common cause of file moving failures is because of bad permissions on the directory attempting to be written to
	// Make sure you chmod the directory to be writeable
	echo "Shtimi i te dhenave NUK u krye me Sukses. Ju lutem provoni <a href=adminsection.php>perseri</a>";
	exit;
}
}

?>[/m]

Link to comment
Share on other sites

heheh yes man thats very true.

 

Now i have another problem with db saying:

 

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 'condition, km, price, picture, date_added) values ('BMW', '1990', 'M', 'N', '4',' at line 1

 

i am truing to correct it but im asking maybe u can help also with this..

 

I really appriciate ur work :)

Link to comment
Share on other sites

Ok now bevayse i dont want to open another topic since the question is related to that im making the question here:

I am trying to show the images from database to the index page however the images are not showing>

WHere is the error?

 

here is the index.php page.

[m]<?php require_once('Connections/ecommerce_dbcon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_ecommerce_dbcon, $ecommerce_dbcon);
$query_FirstPictureRec = "SELECT picture FROM `form` WHERE formid=1";
$FirstPictureRec = mysql_query($query_FirstPictureRec, $ecommerce_dbcon) or die(mysql_error());
$row_FirstPictureRec = mysql_fetch_assoc($FirstPictureRec);
$totalRows_FirstPictureRec = mysql_num_rows($FirstPictureRec);

mysql_select_db($database_ecommerce_dbcon, $ecommerce_dbcon);
$query_SecondPictureRec = "SELECT picture FROM `form` WHERE formid=2";
$SecondPictureRec = mysql_query($query_SecondPictureRec, $ecommerce_dbcon) or die(mysql_error());
$row_SecondPictureRec = mysql_fetch_assoc($SecondPictureRec);
$totalRows_SecondPictureRec = mysql_num_rows($SecondPictureRec);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ecommerce Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- Stylesheets -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/styles.css" />

<!-- Scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.roundabout-1.0.min.js"></script> 
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript">		
	$(document).ready(function() { //Start up our Featured Project Carosuel
		$('#featured ul').roundabout({
			easing: 'easeOutInCirc',
			duration: 600
		});
	});
</script>  

<!--[if IE 6]>
<script src="js/DD_belatedPNG_0.0.8a-min.js"></script>
<script>
  /* EXAMPLE */
  DD_belatedPNG.fix('.button');
  
  /* string argument can be any CSS selector */
  /* .png_bg example is unnecessary */
  /* change it to what suits you! */
</script>
<![endif]-->
</head>
<body>
<div id="wrapper" class="container_12 clearfix">

	<!-- Login Form -->
	<h1 id="login" class="grid_4">
        <form id='login' action="checkAdminLogin.php" method='POST' accept-charset='UTF-8'>
        <fieldset >
        <legend class="meta">Admin Login</legend>
        <input type='hidden' name='submitted' id='submitted' value='1'/>
        <table>
        <tr><th>
        <label for='username'>Name:</label> </th>
     	<td><input type='text' name='username' id='username'  maxlength="50" /> </td></tr>
        <tr><th>
        <label for='password'>Password:</label></th>
        <td><input type='password' name='password' id='password' maxlength="50" /> </td>
        <th><input type='submit' name='Submit' value='Login' /> </th></tr>
        </table>
        </fieldset>
        </form>
        </h1>

	<!-- Navigation Menu -->
	<ul id="navigation" class="grid_8">
		<li><a href="contact.php"><span class="meta">Get in touch</span><br />Contact Us</a></li>
		<li><a href="blog.php"><span class="meta">Latest news</span><br />Blog</a></li>
		<li><a href="portfolio.php"><span class="meta">Our latest work</span><br />Portfolio</a></li>

		<li><a href="about.php"><span class="meta">Who are we?</span><br />About</a></li>
		<li><a href="index.php" class="current"><span class="meta">Homepage</span><br />Home</a></li>
	</ul>

	<div class="hr grid_12"> </div>
	<div class="clear"></div>

	<!-- Featured Image Slider -->
	<div id="featured" class="clearfix grid_12">
		<ul> 
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
				<img src="<?php echo $row_FirstPictureRec['picture']; ?>" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="<?php echo $row_SecondPictureRec['picture']; ?>" alt="" />
				</a>	
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
		</ul> 
</div>
	<div class="hr grid_12 clearfix"> </div>

	<!-- Caption Line -->
	<h2 class="grid_12 caption clearfix">Welcome! This is <span>Aurelius</span>, a slick, professional <u>Business</u> & <u>Portfolio</u> theme built to engage the user in your work.</h2>

	<div class="hr grid_12 clearfix quicknavhr"> </div>
	<div id="quicknav" class="grid_12">
		<a class="quicknavgrid_3 quicknav alpha" href="portfolio.php">
				<h4 class="title ">Recent Work</h4>
				<p>Cras vestibulum lorem et dui mollis sed posuere leo semper. </p>
				<p style="text-align:center;"><img alt="" src="images/Art_Artdesigner.lv.png" /></p>

		</a>
		<a class="quicknavgrid_3 quicknav" href="about.php">
				<h4 class="title ">Learn about us</h4>
				<p>Cras vestibulum lorem et dui mollis sed posuere leo semper. </p>
				<p style="text-align:center;"><img alt="" src="images/info.png" /></p>

		</a>
		<a class="quicknavgrid_3 quicknav" href="blog.php">
				<h4 class="title ">Read our blog</h4>
				<p>Cras vestibulum lorem et dui mollis sed posuere leo semper. </p>
				<p style="text-align:center;"><img alt="" src="images/Blog_Artdesigner.lv.png" /></p>

		</a>
		<a class="quicknavgrid_3 quicknav" href="#">
				<h4 class="title ">Follow on Twitter</h4>
				<p>Cras vestibulum lorem et dui mollis sed posuere leo semper. </p>
				<p style="text-align:center;"><img alt="" src="images/hungry_bird.png" /></p>
		</a>
	</div>
	<div class="hr grid_12 clearfix"> </div>
	<!-- Footer -->
	<p class="grid_12 footer clearfix">
		<span class="float"><b> EpokaUniversity || All Rights Reserved © Copyright</b> || HarisKrasniqi, DiamantNeziri, HarisMemeti, KelmendTairi.</span>
		<a class="float right button" href="#">top</a>
	</p>

</div><!--end wrapper-->
</body>
</html>
<?php
mysql_free_result($FirstPictureRec);

mysql_free_result($SecondPictureRec);
?>
[/m]

Link to comment
Share on other sites

no there is no view image  because its jquery and in front it has a div with href to another page

Then echo the paths out at the top of your page and make sure they reside there.

 

here is the part that im working:

how can i putted at the top of the page? i want it to stay there because its an image slider jquery there

 

<!-- Featured Image Slider -->
	<div id="featured" class="clearfix grid_12">
		<ul> 
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
				<img src="C:\xampp\htdocs\ecommerce\adminform_images\<?php echo $row_FirstPictureRec['picture']; ?>" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="C:\xampp\htdocs\ecommerce\adminform_images\<?php echo $row_SecondPictureRec['picture']; ?>" alt="" />
				</a>	
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
			<li>
				<a href="portfolio_single.php">
					<span>Read about this project</span>
					<img src="images/600x300.gif" alt="" />
				</a>
			</li>  
		</ul> 
</div>

Link to comment
Share on other sites

echo out these values "$row_FirstPictureRec['picture']"  "$row_SecondPictureRec['picture']" right under your second MySQL call.  Then, get the path they print out and try to go to that directory and find the images.

Link to comment
Share on other sites

echo out these values "$row_FirstPictureRec['picture']"  "$row_SecondPictureRec['picture']" right under your second MySQL call.  Then, get the path they print out and try to go to that directory and find the images.

 

they echo out only the picture name

Can you navigate to "C:\xampp\htdocs\ecommerce\adminform_images\{value_of_echo}" and make sure that file exists?

Link to comment
Share on other sites

echo out these values "$row_FirstPictureRec['picture']"  "$row_SecondPictureRec['picture']" right under your second MySQL call.  Then, get the path they print out and try to go to that directory and find the images.

 

they echo out only the picture name

Can you navigate to "C:\xampp\htdocs\ecommerce\adminform_images\{value_of_echo}" and make sure that file exists?

 

yes, the file is there

Link to comment
Share on other sites

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.