MyBB Community Forums

Full Version: Working on a PHP script and I get a blank page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

Page viewer sees first:
Quote:<html>
<head>
<title>Untitled</title>
</head>
<body>

<form action="videoload.php" border="1" method="get">
<table summary="" width="25%" border="1" height="100">
<tr>
<td align="center" valin="middle">
<input type="submit" src="" value="video1" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">

<input type="submit" src="" value="Video2" name="submit" />
</td>
</tr>
<tr>
<td align="center" valin="middle">

<input type="submit" src="" value="video3" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">
<input type="submit" src="" value="video4" name="submit" />
</td>
</tr>
</table>
</form>
</body>
</html>

Result page:
Quote:<?php
$video1 = "{$_GET['video1']}";
$video2 = "{$_GET['video2']}";
$video3 = "{$_GET['video3']}";
$video4 = "{$_GET['video4']}";

if ("$video1") {
echo ("<embed src=\"chimes.wav\" />");
}
if ("$video2") {
echo ("<embed src=\"flourish.mid\" />");
}
if ("$video3") {
echo ("<embed src=\"onestop.mid\" />");
}
if ("$video4") {
echo ("<embed src=\"town.mid\" />");
}
?>

When I make a selection of the first page I get a blank page when the php page loads. I'm testing it using xxamp
You can only have one submit button per form you cant have multiple submit buttons in a form. This is why your script aint working. Also your PHP systax needs to be improved slightly too.

For example this:
$video1 = "{$_GET['video1']}";
should be
$video1 = $_GET['video1'];
the same applies to your if statments too.
<?php
$video1 = $_GET['video1'];
$video2 = $_GET['video2'];
$video3 = $_GET['video3'];
$video4 = $_GET['video4'];

if $video1 = "" {
    echo "Video not selected or whatever";
}
else {
    echo ("<embed src=\"chimes.wav\" />");
}
elseif $video2 = "" {
    echo "Video2 not selected or whatever";
}
else {
    echo ("<embed src=\"flourish.mid\" />");
}
elseif $video3 = "" {
    echo "Video3 not selected or whatever";
}
else {
    echo ("<embed src=\"onestop.mid\" />");
}
elseif $video4 = "" {
    echo "Video4 not selected or whatever";
}
else {
    echo ("<embed src=\"town.mid\" />");
}
?>


i think that should work. I didnt know if you wanted the if somethings not selected message. I or you could always take that out. Poor just realised now it would have been better is i did that empty command thing to see if it was empty but oh well. I think that way will still work.

Btw i dont code php - well hardly somewhere tell me if i went wrong
When I did what you suggested I get:

Parse error: parse error, unexpected T_VARIABLE, expecting '(' in C:\Program Files\xampp\htdocs\Video Script\videoload.php on line 7
The fixed code:

Simulationcity Wrote:Page viewer sees first:
Quote:<html>
<head>
<title>Untitled</title>
</head>
<body>

<form action="videoload.php" border="1" method="get">
<table summary="" width="25%" border="1" height="100">
<tr>
<td align="center" valin="middle">
<input type="submit" src="" value="video1" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">

<input type="submit" src="" value="video2" name="submit" />
</td>
</tr>
<tr>
<td align="center" valin="middle">

<input type="submit" src="" value="video3" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">
<input type="submit" src="" value="video4" name="submit" />
</td>
</tr>
</table>
</form>
</body>
</html>

Result page:
Quote:<?php


if ($_POST['submit'] == 'video1') {
echo ("<embed src=\"chimes.wav\" />");
}
if ($_POST['submit'] == 'video2') {
echo ("<embed src=\"flourish.mid\" />");
}
if ($_POST['submit'] == 'video3') {
echo ("<embed src=\"onestop.mid\" />");
}
if ($_POST['submit'] == 'video4') {
echo ("<embed src=\"town.mid\" />");
}
?>

When I make a selection of the first page I get a blank page when the php page loads. I'm testing it using xxamp

The PHP part can also be done in this form

<?php
switch($_POST['submit']) {
case 'video1': echo ("<embed src=\"chimes.wav\" />"); break;
case 'video2': echo ("<embed src=\"flourish.mid\" />"); break;
case 'video3': echo ("<embed src=\"onestop.mid\" />"); break;
case 'video4': echo ("<embed src=\"town.mid\" />"); break;
}
?>
I don't get what's going on but I still get a blank page for either php options.
Strange?

This works for me:
<html>
<head>
<title>Untitled</title>
</head>
<body>

<?php
switch($_POST['submit']) {
case 'video1': echo ("<embed src=\"chimes.wav\" />"); break;
case 'video2': echo ("<embed src=\"flourish.mid\" />"); break;
case 'video3': echo ("<embed src=\"onestop.mid\" />"); break;
case 'video4': echo ("<embed src=\"town.mid\" />"); break;
}
?>

<form action="" border="1" method="POST">
<table summary="" width="25%" border="1" height="100">
<tr>
<td align="center" valin="middle">
<input type="submit" src="" value="video1" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">

<input type="submit" src="" value="video2" name="submit" />
</td>
</tr>
<tr>
<td align="center" valin="middle">

<input type="submit" src="" value="video3" name="submit" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">
<input type="submit" src="" value="video4" name="submit" />
</td>
</tr>
</table>
</form>
</body>
</html>
has it worked yet? because im pretty sure most of the codes here work. (execpt mine probs). Are you sure you have php on your server?
Yse I do I have MyBB on my webiste and Xampp on my computer which I have a forum installed on(for no reason)

When I run Dale Hay's script I get:

"Parse error: parse error, unexpected T_STRING in /home2/simulati/public_html/preload/video/video2.php on line 9"
Simulationcity Wrote:I don't get what's going on but I still get a blank page for either php options.
this like delahay code but you check it maybe your problem fixed

your html code

<html>
<head>
<title>Untitled</title>
</head>
<body>

<form action="mac.php" border="1" method="post">
<table summary="" width="25%" border="1" height="100">
<tr>
<td align="center" valin="middle">
<input type="submit" src="" value="video1" name="video1" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">

<input type="submit" src="" value="Video2" name="video2" />
</td>
</tr>
<tr>
<td align="center" valin="middle">

<input type="submit" src="" value="video3" name="video3" />
</td><td>&nbsp;&nbsp;&nbsp;</td><td align="center" valin="middle">
<input type="submit" src="" value="video4" name="video4" />
</td>
</tr>
</table>
</form>
</body>
</html>

and your php code

<?php
$video1 = "{$_POST['video1']}";
$video2 = "{$_POST['video2']}";
$video3 = "{$_POST['video3']}";
$video4 = "{$_POST['video4']}";

if ("$video1") {
echo ("<embed src=\"chimes.wav\" />");
}
if ("$video2") {
echo ("<embed src=\"flourish.mid\" />");
}
if ("$video3") {
echo ("<embed src=\"onestop.mid\" />");
}
if ("$video4") {
echo ("<embed src=\"town.mid\" />");
}
?>

[Image: 83.gif]
Pages: 1 2