-
Ok I think this is the last thing... I tried the $email thing and it looks like its gonna work. heres the problem though.
Code:
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
I changed that to this
Code:
// Write $somecontent to our opened file.
if (fwrite($handle, $name, $email, $VideoTitle, $Description) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
Is that correct it doesnt appear so, because when I tried it it didn't roll.
-
You have to place the variables in the variable $somecontent (or any other variable that you want as long as it gets passed to the fwrite function). Have a look at the following:
Code:
<?php
$filename = 'data.txt';
$name = $_POST['name'];
$email = $_POST['email'];
$VideoTitle = $_POST['VideoTitle'];
$Description = $_POST['Description'];
$somecontent = <<<HERE
------------------------
$name
$email
$VideoTitle
$Description
------------------------
HERE;
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
Hope this helps.
-
It does help a little but i get this instead:
Success, wrote ( '' , '' , '' , '' ,) to file (data.txt)
here is the somecontent code i put in:
Code:
$somecontent = " '$name' , '$email' , '$VideoTitle' , '$Description' ,";
Edit:
If it helps i also tried with out the apostrophees ' those things...
-
Are your form field names "name", "email", "VideoTitle", and "Description"? Also, make sure you are passing the form via POST method.
-
Code:
<?php
$filename = 'data.txt';
$name = $_POST['name'];
$email = $_POST['email'];
$VideoTitle = $_POST['VideoTitle'];
$Description = $_POST['Description'];
$somecontent = " '$name' , '$email' , '$VideoTitle' , '$Description' ,"; //THIS PART!
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
I will also confirm that my form is using post and all the names are what they are
-
What should I put in for the php code?
-
The php script you posted above is fine, just make sure that the form fields have the same names as those that you are calling in this part of the php script:
Code:
$name = $_POST['name'];
$email = $_POST['email'];
$VideoTitle = $_POST['VideoTitle'];
$Description = $_POST['Description'];
-
Ok it still isn't working. here is the code i have for both the form and the status page.
HTML Code:
<html>
<head>
<script src="SpryAssets/SpryEffects.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
Original: ArjoGod, Shauna Merritt -->
<!-- Modified By: Ronnie T. Moore, Editor -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
extArray = new Array(".mov", ".mpg", ".mpeg", ".avi", ".swf", ".wmv");
function LimitAttach(form, file) {
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) form.submit();
else
alert("Please only upload files that end in types: "
+ (extArray.join(" ")) + "\nPlease select a new "
+ "file to upload and submit again.");
}
// En
function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
//-->
</script>
<style type="text/css">
html, body, table{
font-family: Tahoma;
font-size: 12px;
color: FFFFFF;
overflow: auto;
scrollbar-face-color: #4e4e4e;
scrollbar-base-color:#444444;
scrollbar-arrow-color: #FFFFFF;
scrollbar-track-color:#444444;
scrollbar-shadow-color:#5e5e5e;
scrollbar-highlight-color:#5e5e5e;
scrollbar-3dlight-color:#444444;
scrollbar-darkshadow-Color:#444444;
}
a:link{
color: FFFFFF;
font-family: Trebuchet Ms;
text-decoration: none;
font-weight: bold;
}
a:hover{
font-family: Trebuchet Ms;
color: 666666;
text-decoration: none;
font-weight: bold;
}
.form{
font-family: Trebuchet Ms;
border-width: 2px;
border-style: solid;
border-color: 4e4e4e;
width: 468px;
height: 400px;
color: FFFFFF;
overflow: none;
scrollbar-face-color: #4e4e4e;
scrollbar-base-color:#444444;
scrollbar-arrow-color: #FFFFFF;
scrollbar-track-color:#444444;
scrollbar-shadow-color:#5e5e5e;
scrollbar-highlight-color:#5e5e5e;
scrollbar-3dlight-color:#444444;
scrollbar-darkshadow-Color:#444444;
}
.input{
width: 180px;
background-color: #5e5e5e;
border-width: 1px;
border-color: #770000;
border-style: solid;
color: #C3C3C3;
font-family: Trebuchet Ms;
font-size: 10px;
}
.smallinput{
width: 90px;
background-color: #5e5e5e;
border-width: 1px;
border-color: #770000;
border-style: solid;
color: #C3C3C3;
font-family: Trebuchet Ms;
font-size: 10px;
}
.form textarea{
width: 275px;
height: 150px;
overflow: auto;
}
.button{
background: url(button.png);
height: 20px;
width: 100px;
border-width: 1px;
border-style: solid;
border-color: #555555;
color: FFFFFF;
font-family: Trebuchet Ms;
font-weight: bold;
}
/*.threepxfix class below:
Targets IE6- ONLY. Adds 3 pixel indent for multi-line form contents.
to account for 3 pixel bug: http://www.positioniseverything.net/explorer/threepxtest.html
*/
* html .threepxfix{
margin-left: 3px;
}
#modernbricksmenu{
padding: 0;
width: 100%;
background: transparent;
voice-family: "\"}\"";
voice-family: inherit;
}
#modernbricksmenu ul{
font: bold 11px Trebuchet Ms;
margin:0;
margin-left: 55px; /*margin between first menu item and left browser edge*/
padding: 0;
list-style: none;
}
#modernbricksmenu li{
display: inline;
margin: 0 2px 0 0;
padding: 0;
text-transform:uppercase;
}
#modernbricksmenu a{
float: left;
display: block;
color: white;
margin: 0 1px 0 0; /*Margin between each menu item*/
padding: 5px 10px;
text-decoration: none;
letter-spacing: 1px;
background-color: #444444 ;
border-bottom: 1px solid #444444;
}
#modernbricksmenu a:hover{
background-color: #770000; /*Menu hover bgcolor*/
border-bottom: 1px solid #770000;
}
#modernbricksmenu #current a{ /*currently selected tab*/
background-color: #D25A0B; /*Brown color theme*/
border-color: #D25A0B; /*Brown color theme*/
}
#modernbricksmenuline{
clear: both;
padding: 0;
width: 100%;
height: 5px;
line-height: 5px;
background: #770000; /*Brown color theme*/
}
</style>
</head>
<body bgcolor="444444" >
<center>
<table width="468" align="center">
<tr>
<td><img src="banner.png" border="0"></td></tr>
<tr>
<td colspan="2">
<div id="modernbricksmenu">
<ul>
<li>
<a href="Index.html">Index</a></li>
<li>
<a href="Videos.html">Videos</a></li>
<li>
<a href="Submit.html">Submit Video</a></li>
<li>
<a href="forum.htm">PureADD Forum</a></li>
</ul>
</div>
<div id="modernbricksmenuline"> </div></td>
</tr>
<tr>
<td width="468" valign="top"><table width="400" border="1" align="center" bordercolor="#4e4e4e">
<tr><form action="status.php" method="post" enctype="text/plain" >
<th width="127" align="right" valign="middle" scope="col"><label>Your Name:</label></th>
<th width="257" align="left" valign="top" scope="col">
<input name="name" type="text" class="input" id="name" maxlength="30">
</th>
</tr>
<tr>
<th align="right" valign="middle" scope="col">Your Email Address:</th>
<th align="left" scope="col"><label>
<input name="email" type="text" class="input" id="email" maxlength="100">
</label></th>
</tr>
<tr>
<th align="right" valign="middle" scope="col">Your Video's Title:</th>
<th align="left" scope="col"><input name="VideoTitle" type="text" class="input" id="VideoTitle" maxlength="20"></th>
</tr>
<tr>
<th align="right" valign="top" scope="col">Video Description:</th>
<th align="left" scope="col"><label>
<textarea name="textarea" cols="45" rows="5" class="input" name="Description" id="Description"></textarea>
</label></th>
</tr>
<tr>
<th align="right" valign="top" scope="col">Our Rules:</th>
<th align="left" valign="top" scope="col"><p>You must read these rules that we have put up to stop spammers and other mean people who like to put up bad videos
which are filled with bad stuff.<br>
<br>
</p></th>
</tr>
<tr>
<th align="center" valign="top" scope="col" colspan="2">
<input name="Submit" type="submit" class="button" id="Submit" value="Submit">
<Br>
</th>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2">
<center><sup>.:: PureADD Videos 2007© :: Designed by PureADD ::.</sup></center>
<div id="modernbricksmenuline"> </div></td>
</table>
</body>
</html>
thats the submition page submition.php
here is the status page status.php
PHP Code:
<?php
$filename = 'data.txt';
$name = $_POST['name'];
$email = $_POST['email'];
$VideoTitle = $_POST['VideoTitle'];
$Description = $_POST['Description'];
$somecontent = " '$name' , '$email' , '$VideoTitle' , '$Description' ,"; //THIS PART!
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
I really hope thats not right
-
Those single quotes are bothering me...
PHP Code:
$somecontent = " '".$name."' , '".$email."' , '".$VideoTitle."' , '".$Description."' ,"; //THIS PART!
-
ok so I entered it and I still don't have any difference other than " , " , " ,