Jump to content

php help - inserting into database


aircooled57

Recommended Posts

Hello all , i would love some help regarding an issue on my website , basically on the admin backend there are features that allow me to add new tutorials to the database and although none of the backend code behind the site has changed as far as i no , the feature no longer works.

 

web form for adding tutorials :

 

<?php
session_start();
{ include"../template/admined.php";
?>

<span class="special-font2" style="margin-left:55px">Add New Tutorial</span>
<form action="submit_tutorial.php" method="post" enctype="multipart/form-data">
<table border="0" style="margin-left:50px">
<tr><td>Type:</td>
<td><select name="type">
<option value="tutorial">Tutorial</option>
<option value="xhtml">XHTML </option>
<option value="myspace">Myspace</option>
<option value="link">Links</option>
<option value="member">Member</option>
</select>
</td></tr>
<tr><td>Judul:</td><td>
<input type="text" name="judul" size="40">
</td></tr>
<tr><td valign="top">Preview:</td><td>
<textarea name="elm" style="width:99%" rows="7">
</textarea>
</td></tr>
<tr><td valign="top">Content:</td><td>
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
	theme : "advanced",
	mode : "exact",
	elements : "elm1,elm2",
	save_callback : "customSave",
	content_css : "example_advanced.css",
	extended_valid_elements : "a[href|target|name]",
	plugins : "table",
	theme_advanced_buttons3_add_before : "tablecontrols,separator",
	//invalid_elements : "a",
	theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1", // Theme specific setting CSS classes
	//execcommand_callback : "myCustomExecCommandHandler",
	debug : false
});

// Custom event handler
function myCustomExecCommandHandler(editor_id, elm, command, user_interface, value) {
	var linkElm, imageElm, inst;

	switch (command) {
		case "mceLink":
			inst = tinyMCE.getInstanceById(editor_id);
			linkElm = tinyMCE.getParentElement(inst.selection.getFocusElement(), "a");

			if (linkElm)
				alert("Link dialog has been overriden. Found link href: " + tinyMCE.getAttrib(linkElm, "href"));
			else
				alert("Link dialog has been overriden.");

			return true;

		case "mceImage":
			inst = tinyMCE.getInstanceById(editor_id);
			imageElm = tinyMCE.getParentElement(inst.selection.getFocusElement(), "img");

			if (imageElm)
				alert("Image dialog has been overriden. Found image src: " + tinyMCE.getAttrib(imageElm, "src"));
			else
				alert("Image dialog has been overriden.");

			return true;
	}

	return false; // Pass to next handler in chain
}

// Custom save callback, gets called when the contents is to be submitted
function customSave(id, content) {

}
</script>
<!-- /tinyMCE -->
<textarea name="elm1" style="width:100%" rows="30" cols="40">

</textarea>
</td></tr>
<tr><td>Icon</td><td>
<input type="file" name="icon">
</td></tr>
<tr><td>Picture</td><td>
<input type="file" name="pict">
</td></tr>
<tr><td>Upload File</td><td>
<input type="file" name="upload">
</td></tr>
<tr><td ></td><td>	<input type="submit" name="submit" value="Add"> 
&nbsp <input type="button" onclick=";self.location.href='admin_tutorial.php'"  value="Cancel" /> </td></tr> </table>
</form>


<?
}


?>

</div>

<div class="clear"></div>
<div id="footer">
<span style="float:right; margin:5px 25px 0 0; color:#5a5a5a">© Copyright 2008 <strong><a href="#">Purple Fusion</a></strong> - All Rights Reserved</span>
    <span style="float:left; margin:5px 0 0 45px; color:#5a5a5a"><a href="http://validator.w3.org/check?uri=referer">HTML Validation</a>   |   <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS Validation</a></span>
</div>
</body>
</html>

 

 

 

 

This is the script that sends information in webform to a database , this file is called submit_tutorial.php

 

<?
session_start();
include"../template/admined.php";
include"../config.php";

if($submit)
{ 

if(!empty($judul) && !empty($pict) && !empty($icon) && !empty($upload) && !empty($elm) && !empty($elm1))
{
	$location = "./images/".$HTTP_POST_FILES['pict']['name'];
	$location1 = "./images/".$HTTP_POST_FILES['icon']['name'];
	$location2 = "./file/".$HTTP_POST_FILES['upload']['name'];
	move_uploaded_file($pict, $location);
	move_uploaded_file($icon, $location1);
	move_uploaded_file($upload, $location2);
	mysql_query("INSERT INTO tutorial(id,title,preview,details,picture,icon,type,file) values('','$judul','$elm','$elm1','$location','$location1','$type','$location2')") or die(mysql_error());
	echo "<center>Succesfully Added <a href='admin_tutorial.php'>Back</a>";


}else{
	echo"<script>alert('Should not empty');history.go(-1)</script>";

}

}else{ echo"<script>alert('Failed to edit');history.go(-1)</script>";

}

?>

</div>

<div class="clear"></div>
<div id="footer">
<span style="float:right; margin:5px 25px 0 0; color:#5a5a5a">© Copyright 2008 <strong><a href="#">Purple Fusion</a></strong> - All Rights Reserved</span>
    <span style="float:left; margin:5px 0 0 45px; color:#5a5a5a"><a href="http://validator.w3.org/check?uri=referer">HTML Validation</a>   |   <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS Validation</a></span>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/134529-php-help-inserting-into-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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