Teensweb
New Member
- Messages
- 352
- Reaction score
- 1
- Points
- 0
I have a form-
the addfile.php is-
The form doesn't submit but refreshes! can anyone help?
HTML:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#demo').hide();
$('#picker').farbtastic('#color');
});
function submitform()
{
document.form1.submit();
}
</script>
</head>
<body>
<div style="position: absolute; width: 557px; height: 100px; z-index: 4; left: 202px; top: 264px" id="layer2">
<form action="addfile.php" name="form1" id="form1" class=form1 onsubmit="return false;" >
<p><font color="#1E3973">Product name :</font>
<input type="text" class=medium name="file_name" maxlength="7" />
<p>
<p><font color="#1E3973">Show out of 5</font>
<select name="number" size="1">
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</p>
<p><font color="#1E3973">Show Percentage</font>
<select name="percent" size="1">
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</p>
<p><font color="#1E3973">Show number of votes</font>
<select name="votes" size="1">
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</p>
<p><font color="#1E3973">Image Type</font>
<select name="extension" size="1">
<option value="png">PNG</option>
<option value="gif">GIF</option>
</select><br>
<br><input type="checkbox" class="styled" />
<font color="#1E3973">Transperent</font><br>
<div class="form-item"><font color="#1E3973">Back ground </font><label for="color">
<font color="#1E3973">Color: </font></label><input type="text" id="color" name="color" value="#000000" /></div>
<div style="position: absolute; width: 68px; height: 70px; z-index: 4; left: 352px; top: 102px" id="picker"></div>
<div style="position: absolute; width: 68px; height: 70px; z-index: 4; left: 312px; top: 195px" id="colorpicker"></div>
<font color="#1E3973">Type a color value or select from the color<br>picker on the right. (Default is
</font><b>black</b><font color="#1E3973">)</font><br><br><br>
<a href="javascript: submitform()" class="button" cursor=pointer ><span class=cursor >Create!</span></a></p>
PHP:
<?php
require ( '/home/avin/public_html/teensweb.co.cc/Login/settings.php' );
?>
<?php
if(isset($_POST['submit'])) //has the form been submitted?
{
$id = $login->get_username ( $_SESSION [ AUTH_SESSION_ID ] );
$file_directory = "files/"; //the directory you want to store the new file in
$file_name = strip_tags($_POST['file_name']);//the file's name, stripped of any dangerous tags
$prefix = "$id-$file_name";
$file_ext = ".php"; //the file's extension, stripped of any dangerous tags
$file = $file_directory.$prefix.$file_ext; //this is the entire filename
$outof = strip_tags($_POST['number']);
$percent = strip_tags($_POST['percent']);
$votes = strip_tags($_POST['votes']);
$tagopen = '<?';
$tagclose = '?>';
$color = strip_tags($_POST['color']);
$votes = strip_tags($_POST['votes']);
$css = strip_tags($_POST['extension']);
$html = '<body';
$htclose = '>';
$filename = "files/$id-$file_name$file_ext";
$background = "$html bgcolor=$color$htclose";
if (file_exists($filename))
{
unlink($filename);
}
$create_file = fopen($file, "w+"); //create the new file
if ($css = png) {
$content = '<? include("includes/rating_functions.php"); ?>
<link href="css/rating_style.css" rel="stylesheet" type="text/css" media="all">
<script type="text/javascript" src="js/rating_update.js"></script>';
}
else {
$content = '<? include("includes/rating_functions.php"); ?>
<link href="css/rating_style_gif.css" rel="stylesheet" type="text/css" media="all">
<script type="text/javascript" src="js/rating_update.js"></script>';
}
$phfiles = "$tagopen echo pullRating($file_name,$outof,$percent,$votes) $tagclose";
$code = 'Rating sytem created success fully! copy and paste the following code where you want the stars to appear<textarea rows="5" cols="50"><iframe src=http://www.teensweb.co.cc/' . $filename . ' frameborder="0" ></textarea>';
if(!$create_file)
{
die("There was an error creating/opening the file! Make sure you have the correct permissions!\n");
}
$chmod = chmod($file, 7545); //set the appropriate permissions.
//attempt to set the permissions
if(!$chmod)
{
echo("There was an error changing the permissions of the new file!\n"); //error changing the file's permissions
}
//attempt to write basic content to the file
if (fwrite($create_file, "$content$phfiles$background") === FALSE) {
echo "Error writing to file: ($file)\n";
}
fclose($create_file);
}else{ //the form hasn't been submitted!
header("Location: addfile.html"); //redirect the user back to the add file page
}
if($create_file)
{echo $code;}
?>