Jump to content

[SOLVED] My Form Doesn't Work...


tarun

Recommended Posts

Ive Had Previous Help With This But Now Theres ANOTHER Problem:

 

The Form Wont Submit - Why?

Please Help Me Thnx

 

Heres My Source Code

<?php
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit'>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

Link to comment
https://forums.phpfreaks.com/topic/43029-solved-my-form-doesnt-work/
Share on other sites

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit'>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

$PHP_SELF shouldn't work without defining it first.

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

 

That was what I changed above.

 

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$addform = "<form name='addvideo' action='$PHP_SELF' method='post'>

Video URL:<BR><input type='text' name='url' size='40'>

<br>Video Description:<br><textarea rows='10' cols='30' name='desc'></textarea><br></form>

<input type='submit' value='Submit' name="Submit"></form>";

echo "$addform";

if (isset($_POST['Submit'])) {


$url = $_POST['url'];
$desc = $_POST['desc'];

if(empty($url)){
echo "Please Specify The URL Of The Video<br>";
}

elseif(empty($desc)){
echo "Please Specify A Description Of The Video<br>";
}

else{
$newcontent = "<videos>
<video url='$url' desc='$desc' />
</videos>";
$previouscontent = file_get_contents("videoplaylist.xml");
$openfile = fopen("videoplaylist.xml", "w");
$totalfile = $previouscontent.$newcontent;
fwrite($openfile, $totalfile);
fclose($openfile);

echo "File Added To Playlist<br><br>Add A New File?<br>$addform";
}


}
?>

 

I changed the : <input type='submit' value='Submit' name="Submit"></form>"; this time around, see if that works.

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.