Jump to content

bonito1

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bonito1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. this is my code <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <p> <label for="onoma">Όνομα<br /> </label> <input name="onoma" type="text" id="onoma" size="40" /> </p> <p> <label for="epitheto">Επίθετο</label> <br /> <input name="epitheto" type="text" id="epitheto" size="40" /> </p> <p> <label for="Email">Email<br /> </label> <input name="Email" type="text" id="Email" size="40" /> </p> <p> <label for="Thlefono">Τηλέφωνο</label> <br /> <input name="Thlefono" type="text" id="Thlefono" size="40" /> </p> <p>Διεύθυνση<br /> <label for="die"></label> <input name="die" type="text" id="die" size="40" /> </p> <p>Ημερομηνία που επιθειμείτε να γίνει η Κρατηση<br /> <input name="hmerominia" type="text" id="hmerominia" size="40" /> </p> <p>Ωρα στην παραπάνω ημερομηνία που επιθειμείτε <input name="wra" type="text" id="wra" size="40" /> </p> <p> <label for="Minima">Άλλο Μύνημα</label> <br /> <textarea name="Minima" id="Minima" cols="50" rows="10"></textarea> </p> <p> <input type="submit" name="submit" id="submit" value="Submit" /> </p> <input type="hidden" name="MM_insert" value="form1" /> <br/> </form> <?php if (is_null($_POST)) { echo "<h4>Η επικύρωση της κράτησης θα γίνει απο εμάς τηλεφωνικά<br /> στο τηλέφωνο που εισάγατε. </h4> <h4>Η διαδικασία κράτησης διαρκεί 1 ημέρα</h4>"; } else{ echo "eyxaristoume kyrie"; echo $_REQUEST["onoma"]; echo " "; echo $_REQUEST["epitheto"]; echo "poy kanante kratisi sto katastima maestros" ;} ?> and this is the form action <?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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO kratisi (onoma, epi8eto, thlefono, dieuthinsi, email, hmerominia, wra, minima) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['onoma'], "text"), GetSQLValueString($_POST['epitheto'], "text"), GetSQLValueString($_POST['Thlefono'], "text"), GetSQLValueString($_POST['die'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['hmerominia'], "text"), GetSQLValueString($_POST['wra'], "text"), GetSQLValueString($_POST['Minima'], "text")); mysql_select_db($database_maestr, $maestr); $Result1 = mysql_query($insertSQL, $maestr) or die(mysql_error()); $insertGoTo = "contact.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> i want to make the form work like this when someone gets to that for first time to say something at the bottom and when he pushes the submit button it will say thank you i tried to do it with post if post is empty to say something and when it isnt empty to say thank you but it doesnt work where is my fault if someone can help me..
  2. cant understand what r you saying can you explain?
  3. it is php_test but it isnt that it makes the difference ..any other ideas?
  4. i have this script called view.php <?php include 'db.inc'; $file = clean($file, 4); if (empty($file)) exit; if (!($connection = @ mysql_pconnect($hostName, $username, $password))) showerror(); if (!mysql_select_db("Php_test", $connection)) showerror(); $query = "SELECT mime, data FROM file WHERE id = $file"; if (!($result = @ mysql_query ($query,$connection))) showerror(); $data = @ mysql_fetch_array($result); if (!empty($data["data"])) { // Output the MIME header header("Content-Type: {$data["mime"]}"); // Output the image echo $data["data"]; } ?> after i have db.inc <?php // These are the DBMS credentials $hostName = "localhost"; $username = "root"; $password = "oxioxi"; // Show an error and stop the script function showerror() { if (mysql_error()) die("Error " . mysql_errno() . " : " . mysql_error()); else die("Could not connect to the DBMS"); } // Secure the user data by escaping characters // and shortening the input string function clean($input, $maxlength) { $input = substr($input, 0, $maxlength); $input = EscapeShellCmd($input); return ($input); } ?> and i have my page witch part of it is this <?php include 'db.inc'; $query = "SELECT id, name, mime FROM file"; if (!($connection = @ mysql_pconnect($hostName, $username, $password))) showerror(); if (!mysql_select_db("php_test", $connection)) showerror(); if (!($result = @ mysql_query ($query, $connection))) showerror(); ?> <h1>Image database</h1> <?php if ($row = @ mysql_fetch_array($result)) { ?> <table> <col span="1" align="right"> <tr> <th>Short description</th> <th>File type</th> <th>Image</th> </tr> <?php do { ?> <tr> <td><?php echo "{$row["name"]}";?></td> <td><?php echo "{$row["mime"]}";?></td> <td><?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td> </tr> <?php } while ($row = @ mysql_fetch_array($result)); ?> </table> <?php } // if mysql_fetch_array() else echo "<h3>There are no images to display</h3>\n"; ?> i have do it right but for some reason it doesnt displays the pictures the type and the name are displayed normally but not the picture!! instead of them there are small icons of not existing pictures.. plz i want help i really need to do it
  5. soz ok i will know it ty any help will be valueble
  6. <?php require_once('Connections/check_mag.php'); ?> what goes wrong with that code and when i push a link for another post in my page nothing changes? where is the wrong plzzzzz help i cant understand im looking for this for 5 days and i cant find the mistake pllzzzzzzzz heellp . if you write your cooment plz give me details because i cant understand very well everything thanx for everythin:) <?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_check_mag, $check_mag); $query_getArchives = "SELECT DISTINCT DATE_FORMAT(news.updated, '%M %Y') AS archive, DATE_FORMAT(news.updated, '%Y-%m') AS link FROM news ORDER BY news.updated DESC "; $getArchives = mysql_query($query_getArchives, $check_mag) or die(mysql_error()); $row_getArchives = mysql_fetch_assoc($getArchives); $totalRows_getArchives = mysql_num_rows($getArchives); mysql_select_db($database_check_mag, $check_mag); $query_getRecent = "SELECT news.post_id, news.title FROM news ORDER BY news.updated DESC LIMIT 10 "; $getRecent = mysql_query($query_getRecent, $check_mag) or die(mysql_error()); $row_getRecent = mysql_fetch_assoc($getRecent); $totalRows_getRecent = mysql_num_rows($getRecent); mysql_select_db($database_check_mag, $check_mag); $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 "; $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); $var1_getdisplay2 = "-1"; if (isset($_GET['archive'])) { $var1_getdisplay2 = $_GET['archive']; $query_getdisplay = sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE DATE_FORMAT(news.updated, '%%Y-%%m') = %s ORDER BY news.updated DESC ", GetSQLValueString($var1_getdisplay2, "text")); }elseif (isset($_GET['post_id'])) { $var2_getdisplay3 = $_GET['post_id']; $query_getdisplay= sprintf("SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%%M %%e, %%Y') AS formatted FROM news WHERE news.post_id = %s ", GetSQLValueString($var2_getdisplay3, "int")); }else{ $query_getDisplay = "SELECT news.title, news.blog_entry, DATE_FORMAT(news.updated, '%M %e, %Y') AS formatted FROM news ORDER BY news.updated DESC LIMIT 2 ";} $getDisplay = mysql_query($query_getDisplay, $check_mag) or die(mysql_error()); $row_getDisplay = mysql_fetch_assoc($getDisplay); $totalRows_getDisplay = mysql_num_rows($getDisplay); ?> <!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"><!-- InstanceBegin template="/Templates/totemp.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="robots" content="index, follow" /> <meta name="keywords" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <meta name="description" content="Σύλλογος Ηπειρωτών Πιερίας,Χορευτικός Σύλλογος,Χορός,Χορευτής,Ήπειρος,SYLLOGOS HPIROTON PIERIAS,pieria,ΠΙΕΡΙΑ" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Check Magazine</title> <!-- InstanceEndEditable --> <link href="styles/check_cs5.css" rel="stylesheet" type="text/css" /> <link href="styles/check_menu.css" rel="stylesheet" type="text/css" /> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> </head> <body> <!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag--> <!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** --> <script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="798";awmAltUrl="";</script><script charset="UTF-8" src="menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script> <!-- ******** END ALLWEBMENUS CODE FOR menu ******** --> <div id="container"> <h1>Check Magazine: Fashion and Lifestyle</h1> <div id="eikona"><img src="images/silogos.jpg" width="1211" height="134" alt="silogos" /></div> <div id="bara"> <p> </p> </div> <!-- InstanceBeginEditable name="EditRegion3" --> <div id="blog"> <p> </p> <div id="archive"> <h3>Archives</h3> <ul><?php do{?> <li><a href="news1.php"> <a href="news1.php"><?php echo $row_getArchives['archive'];?></a><a></li> <?php } while ($row_getArchives=mysql_fetch_assoc($getArchives));?> </ul> </div> <div id="recent"> <h3>RECENT</h3> <ul> <?php do { ?> <li><a href="news1.php?post_id=<?php echo $row_getRecent['post_id']; ?>"><?php echo $row_getRecent['title']; ?></a></li> <?php } while ($row_getRecent = mysql_fetch_assoc($getRecent)); ?> </ul> </div> <div id="blog_posts"> <?php do { ?> <h2><?php echo $row_getDisplay['title']; ?></h2> <p>Uploaded on <?php echo $row_getDisplay['formatted']; ?></p> <p><?php echo nl2br($row_getDisplay['blog_entry']); ?></p> <?php } while ($row_getDisplay = mysql_fetch_assoc($getDisplay)); ?> </div> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <!-- InstanceEndEditable --> <p> </p> </div> </body> <!-- InstanceEnd --></html> <?php mysql_free_result($getArchives); mysql_free_result($getRecent); mysql_free_result($getDisplay); ?>
  7. This is the code that im trying to connect my sql database with php in order to upload images everything works perfect except the fact that the image doesn't upload to the database plzz i want help .... HEEEEEEEEEEEEEEEEEEEEEEELLLPPPP <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php define ('MAX_FILE_SIZE', 1024 * 300000000000); ?> <?php require_once('../Connections/check_mag.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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "uploadImage")) { // make sure it's a genuine file upload if (is_uploaded_file($_FILES['image']['tmp_name'])) { // replace any spaces in original filename with underscores $filename = str_replace(' ', '_', $_FILES['image']['name']); // get the MIME type $mimetype = $_FILES['image']['type']; if ($mimetype == 'image/pjpeg') { $mimetype= 'image/jpeg'; } // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/png'); // upload if file is OK if (in_array($mimetype, $permitted) && $_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { switch ($_FILES['image']['error']) { case 0: // get the file contents $image = file_get_contents($_FILES['image']['tmp_name']); // get the width and height $size = getimagesize($_FILES['image']['tmp_name']); $width = $size[0]; $height = $size[1]; $insertSQL = sprintf("INSERT INTO images (filename, mimetype, caption, image, width, height) VALUES (%s, %s, %s, %s, %s, %s)", GetSQLValueString($filename, "text"), GetSQLValueString($mimetype, "text"), GetSQLValueString($_POST['caption'], "text"), GetSQLValueString($image, "text"), GetSQLValueString($width, "int"), GetSQLValueString($height, "int")); mysql_select_db($database_check_mag, $check_mag); $Result1 = mysql_query($insertSQL, $check_mag) or die(mysql_error()); if ($Result1) { $result = "$filename uploaded successfully."; } else { $result = "Error uploading $filename. Please try again."; } break; case 3: case 6: case 7: case 8: $result = "Error uploading $filename. Please try again."; break; case 4: $result = "You didn't select a file to be uploaded."; } } else { $result = "$filename is either too big or not an image."; } } } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>File upload to database</title> </head> <body> <?php // if the form has been submitted, display result if (isset($result)) { echo "<p><strong>$result</strong></p>"; } ?> <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <p> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <label for="image">Upload image:</label> <input type="file" name="image" id="image" /> </p> <p> <label for="caption">Caption:</label> <input type="text" name="caption" id="caption" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p> <input type="hidden" name="MM_insert" value="uploadImage" /> </form> </body> </html>
×
×
  • 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.