Hidden value in <a Href ...> doorsturen
ik wil graag een variabele versturen naar hetzelfde script, zodra op de link in dit script wordt geklikt.
Deze heb ik liever echter niet in de url zelf (als $_GET) maar graag als $_POST.
Heeft iemand er een oplossing voor?
Alvast bedankt!
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
IF ($_GET["v"] == "")
{ header("location: index.html"); }
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("youtube", $con) or die('Could not find database: ' . mysql_error());
IF ($_GET['a'] == "")
{$views = mysql_result ( mysql_query ("SELECT Views FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_views = $views + 1;
$update = mysql_query ( "UPDATE Video SET Views='". $new_views ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_GET['a'] == "U")
{$likes = mysql_result ( mysql_query ("SELECT Likes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_likes = $likes + 1;
$update = mysql_query ( "UPDATE Video SET Likes='". $new_likes ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_GET['a'] == "D")
{$dislikes = mysql_result ( mysql_query ("SELECT Dislikes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_dislikes = $dislikes + 1;
$update = mysql_query ( "UPDATE Video SET Dislikes='". $new_dislikes ."' WHERE path = '".$_GET['v'] ."' ");
}
// Get Info
$uploader = mysql_result ( mysql_query ("SELECT Username FROM User WHERE id IN ( SELECT Madeby_id FROM Video WHERE path = '". $_GET['v'] ."' )"), 0);
$name = mysql_result ( mysql_query ("SELECT Name FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$description = mysql_result ( mysql_query ("SELECT Description FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$numbers = mysql_fetch_assoc ( mysql_query ("SELECT Views, Likes, Dislikes, Day, Month, Year FROM Video WHERE path = '". $_GET['v'] ."' ") );
?>
<html>
<head>
<title><?php echo $name, " - ", $uploader; ?></title>
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
<script>jwplayer.key="X4FIlFuJ8eokMsDRVDCbEblwQx0t6Iew445eQw=="</script> <!-- License Key -->
</head>
<body bgcolor="#DFDFDF">
<center><big>Video! <?php echo $name, " - ", $uploader; ?></big>
<table border=1 width=480 height=270><tr><td>
<script type='text/javascript' src="/jwplayer/jwplayer.js"> </script>
<div id='thePlayer' />
<script type="text/javascript">
jwplayer('thePlayer').setup({
flashplayer: "jwplayer.flash.swf",
file: "/videos/<?php echo $_GET["v"]; ?>.flv",
width: "480",
height: "270",
autostart: "false",
image: "/images/play.png"
});
</script></td></tr>
<tr><td>
Geupload door: <a href="/profiles.php?p=<?php echo $uploader, '">', $uploader; ?></a>
<div style="float: right"> <?php echo $numbers['Likes'], " UP -- ", $numbers['Dislikes'], " DOWN"; ?> </div>
<br>Op datum: <?php echo $numbers['Day']," - ", $numbers['Month'], " - ", $numbers['Year']; ?>
<br> <?php echo $numbers['Views'], " keer bekeken"; ?>
<br><br>Beschrijving:
<br><?php echo $description; ?>
</td></tr></table>
<a href="index.html">Hoofdpagina</a>
<br><br>
<form action="" method="get"> <b>Ga naar een ander filmpje:</b>
<br><input type="text" name="v"> <input type="submit" value="Gaan!"> </form>
</center>
</body>
</html>
IF ($_GET["v"] == "")
{ header("location: index.html"); }
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("youtube", $con) or die('Could not find database: ' . mysql_error());
IF ($_GET['a'] == "")
{$views = mysql_result ( mysql_query ("SELECT Views FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_views = $views + 1;
$update = mysql_query ( "UPDATE Video SET Views='". $new_views ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_GET['a'] == "U")
{$likes = mysql_result ( mysql_query ("SELECT Likes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_likes = $likes + 1;
$update = mysql_query ( "UPDATE Video SET Likes='". $new_likes ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_GET['a'] == "D")
{$dislikes = mysql_result ( mysql_query ("SELECT Dislikes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_dislikes = $dislikes + 1;
$update = mysql_query ( "UPDATE Video SET Dislikes='". $new_dislikes ."' WHERE path = '".$_GET['v'] ."' ");
}
// Get Info
$uploader = mysql_result ( mysql_query ("SELECT Username FROM User WHERE id IN ( SELECT Madeby_id FROM Video WHERE path = '". $_GET['v'] ."' )"), 0);
$name = mysql_result ( mysql_query ("SELECT Name FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$description = mysql_result ( mysql_query ("SELECT Description FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$numbers = mysql_fetch_assoc ( mysql_query ("SELECT Views, Likes, Dislikes, Day, Month, Year FROM Video WHERE path = '". $_GET['v'] ."' ") );
?>
<html>
<head>
<title><?php echo $name, " - ", $uploader; ?></title>
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
<script>jwplayer.key="X4FIlFuJ8eokMsDRVDCbEblwQx0t6Iew445eQw=="</script> <!-- License Key -->
</head>
<body bgcolor="#DFDFDF">
<center><big>Video! <?php echo $name, " - ", $uploader; ?></big>
<table border=1 width=480 height=270><tr><td>
<script type='text/javascript' src="/jwplayer/jwplayer.js"> </script>
<div id='thePlayer' />
<script type="text/javascript">
jwplayer('thePlayer').setup({
flashplayer: "jwplayer.flash.swf",
file: "/videos/<?php echo $_GET["v"]; ?>.flv",
width: "480",
height: "270",
autostart: "false",
image: "/images/play.png"
});
</script></td></tr>
<tr><td>
Geupload door: <a href="/profiles.php?p=<?php echo $uploader, '">', $uploader; ?></a>
<div style="float: right"> <?php echo $numbers['Likes'], " UP -- ", $numbers['Dislikes'], " DOWN"; ?> </div>
<br>Op datum: <?php echo $numbers['Day']," - ", $numbers['Month'], " - ", $numbers['Year']; ?>
<br> <?php echo $numbers['Views'], " keer bekeken"; ?>
<br><br>Beschrijving:
<br><?php echo $description; ?>
</td></tr></table>
<a href="index.html">Hoofdpagina</a>
<br><br>
<form action="" method="get"> <b>Ga naar een ander filmpje:</b>
<br><input type="text" name="v"> <input type="submit" value="Gaan!"> </form>
</center>
</body>
</html>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
echo 'post ontvangen: '.$_POST['postthis'].'<br/>';
?>
<html>
<head>
<title>post link</title>
<script>
// variabele i willen we posten.
var i = 4;
window.onload = function() {
var postme = document.getElementById('postme');
var postthis = document.getElementById('postthis');
postme.onclick = function() {
postthis.value = i;
postthis.form.submit();
return false;
}
}
</script>
</head>
<body>
<a id='postme' href="#" >klik</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" id="postthis" name="postthis" />
</form>
</body>
</html>
if($_SERVER['REQUEST_METHOD'] == 'POST')
echo 'post ontvangen: '.$_POST['postthis'].'<br/>';
?>
<html>
<head>
<title>post link</title>
<script>
// variabele i willen we posten.
var i = 4;
window.onload = function() {
var postme = document.getElementById('postme');
var postthis = document.getElementById('postthis');
postme.onclick = function() {
postthis.value = i;
postthis.form.submit();
return false;
}
}
</script>
</head>
<body>
<a id='postme' href="#" >klik</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" id="postthis" name="postthis" />
</form>
</body>
</html>
Toevoeging op 18/03/2013 23:12:57:
of:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
echo 'post ontvangen: '.$_POST['postthis'].'<br/>';
?>
<html>
<head>
<title>post link</title>
<style>
input.link {
border:none;
background-color:transparent;
color:blue;
text-decoration:underline;
}
input.link:hover {
cursor:pointer;
}
</style>
<script>
// variabele i willen we posten.
var i = 4;
window.onload = function() {
document.getElementById('postthis').value = i;
}
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" id="postthis" name="postthis" />
<input type="submit" class="link" value="klik" />
</form>
</body>
</html>
if($_SERVER['REQUEST_METHOD'] == 'POST')
echo 'post ontvangen: '.$_POST['postthis'].'<br/>';
?>
<html>
<head>
<title>post link</title>
<style>
input.link {
border:none;
background-color:transparent;
color:blue;
text-decoration:underline;
}
input.link:hover {
cursor:pointer;
}
</style>
<script>
// variabele i willen we posten.
var i = 4;
window.onload = function() {
document.getElementById('postthis').value = i;
}
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" id="postthis" name="postthis" />
<input type="submit" class="link" value="klik" />
</form>
</body>
</html>
kan dat in een paar regeltjes?
Anders maak ik er een form submit knop van.
Staat niet heel erg mooi, maar ach.
Toevoeging op 20/03/2013 22:50:35:
Ik heb het geregeld met een form post.
Hij doet het nog niet.
Ik zit nu ermee dat de text niet goed komt.
Ik gebruik (zie regel 62)
Code (php)
1
div style="float: right"> <?php echo $numbers['Likes'], $voteup, " -- ", $numbers['Dislikes'], $votedn; ?> </div>
dan komt het wel in de tabel te staan, maar elk getal, knop en de streepjes komen op een nieuwe regel te staan.
Als ik echter style="text-align: right" gebruik, dan komen er ook nog echt "witregels" tussen te staan.
Heeft iemand een oplossing waarmee ik de hele regel variabelen ook echt op dezelfde regel in de tabel krijg?
Alvast bedankt!
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
IF ($_GET["v"] == "")
{ header("location: index.html"); }
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("youtube", $con) or die('Could not find database: ' . mysql_error());
// Views, Likes of Dislikes bijwerken
$views = mysql_result ( mysql_query ("SELECT Views FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_views = $views + 1;
$update = mysql_query ( "UPDATE Video SET Views='". $new_views ."' WHERE path = '".$_GET['v'] ."' ");
IF ($_POST['vote'] == "up")
{$likes = mysql_result ( mysql_query ("SELECT Likes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_likes = $likes + 1;
$update = mysql_query ( "UPDATE Video SET Likes='". $new_likes ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_POST['vote'] == "dn")
{$dislikes = mysql_result ( mysql_query ("SELECT Dislikes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_dislikes = $dislikes + 1;
$update = mysql_query ( "UPDATE Video SET Dislikes='". $new_dislikes ."' WHERE path = '".$_GET['v'] ."' ");
}
// Get Info
$uploader = mysql_result ( mysql_query ("SELECT Madeby FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$filename = mysql_result ( mysql_query ("SELECT Filename FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$name = mysql_result ( mysql_query ("SELECT Name FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$description = mysql_result ( mysql_query ("SELECT Description FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$numbers = mysql_fetch_assoc ( mysql_query ("SELECT Views, Likes, Dislikes, Day, Month, Year FROM Video WHERE path = '". $_GET['v'] ."' ") );
// Vote knoppen aanmaken
$voteup = "<form action='' method='post'> <input type='hidden' name='vote' value='up'> <input type='submit' value='UP'> </form>";
$votedn = "<form action='' method='post'> <input type='hidden' name='vote' value='dn'> <input type='submit' value='DOWN'> </form>";
?>
<html>
<head>
<title><?php echo $name, " - ", $uploader; ?></title>
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
<script>jwplayer.key="X4FIlFuJ8eokMsDRVDCbEblwQx0t6Iew445eQw=="</script> <!-- License Key -->
</head>
<body bgcolor="#DFDFDF">
<center><big>Video! <?php echo $name, " - ", $uploader; ?></big>
<table border=1 width=480 height=270><tr><td>
<script type='text/javascript' src="/jwplayer/jwplayer.js"> </script>
<div id='thePlayer' />
<script type="text/javascript">
jwplayer('thePlayer').setup({
flashplayer: "jwplayer.flash.swf",
file: "/uploads/<?php echo $filename; ?>",
width: "480",
height: "270",
autostart: "false",
image: "/images/play.png"
});
</script></td></tr>
<tr><td>
Geupload door: <a href="/profiles.php?p=<?php echo $uploader, '">', $uploader; ?></a>
<div style="float: right"> <?php echo $numbers['Likes'], $voteup, " -- ", $numbers['Dislikes'], $votedn; ?> </div>
<br>Op datum: <?php echo $numbers['Day']," - ", $numbers['Month'], " - ", $numbers['Year']; ?>
<br> <?php echo $numbers['Views'], " keer bekeken"; ?>
<br><br>Beschrijving:
<br><?php echo $description; ?>
</td></tr></table>
<a href="index.html">Hoofdpagina</a>
<br><br>
<form action="" method="get"> <b>Ga naar een ander filmpje:</b>
<br><input type="text" name="v"> <input type="submit" value="Gaan!"> </form>
</center>
</body>
</html>
IF ($_GET["v"] == "")
{ header("location: index.html"); }
$con = mysql_connect("localhost","root","") or die('Could not connect: ' . mysql_error());
mysql_select_db("youtube", $con) or die('Could not find database: ' . mysql_error());
// Views, Likes of Dislikes bijwerken
$views = mysql_result ( mysql_query ("SELECT Views FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_views = $views + 1;
$update = mysql_query ( "UPDATE Video SET Views='". $new_views ."' WHERE path = '".$_GET['v'] ."' ");
IF ($_POST['vote'] == "up")
{$likes = mysql_result ( mysql_query ("SELECT Likes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_likes = $likes + 1;
$update = mysql_query ( "UPDATE Video SET Likes='". $new_likes ."' WHERE path = '".$_GET['v'] ."' ");
}
ELSE IF ($_POST['vote'] == "dn")
{$dislikes = mysql_result ( mysql_query ("SELECT Dislikes FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$new_dislikes = $dislikes + 1;
$update = mysql_query ( "UPDATE Video SET Dislikes='". $new_dislikes ."' WHERE path = '".$_GET['v'] ."' ");
}
// Get Info
$uploader = mysql_result ( mysql_query ("SELECT Madeby FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$filename = mysql_result ( mysql_query ("SELECT Filename FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$name = mysql_result ( mysql_query ("SELECT Name FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$description = mysql_result ( mysql_query ("SELECT Description FROM Video WHERE path = '". $_GET['v'] ."' "), 0);
$numbers = mysql_fetch_assoc ( mysql_query ("SELECT Views, Likes, Dislikes, Day, Month, Year FROM Video WHERE path = '". $_GET['v'] ."' ") );
// Vote knoppen aanmaken
$voteup = "<form action='' method='post'> <input type='hidden' name='vote' value='up'> <input type='submit' value='UP'> </form>";
$votedn = "<form action='' method='post'> <input type='hidden' name='vote' value='dn'> <input type='submit' value='DOWN'> </form>";
?>
<html>
<head>
<title><?php echo $name, " - ", $uploader; ?></title>
<link rel="icon" type="image/ico" href="/images/favicon.ico" />
<script>jwplayer.key="X4FIlFuJ8eokMsDRVDCbEblwQx0t6Iew445eQw=="</script> <!-- License Key -->
</head>
<body bgcolor="#DFDFDF">
<center><big>Video! <?php echo $name, " - ", $uploader; ?></big>
<table border=1 width=480 height=270><tr><td>
<script type='text/javascript' src="/jwplayer/jwplayer.js"> </script>
<div id='thePlayer' />
<script type="text/javascript">
jwplayer('thePlayer').setup({
flashplayer: "jwplayer.flash.swf",
file: "/uploads/<?php echo $filename; ?>",
width: "480",
height: "270",
autostart: "false",
image: "/images/play.png"
});
</script></td></tr>
<tr><td>
Geupload door: <a href="/profiles.php?p=<?php echo $uploader, '">', $uploader; ?></a>
<div style="float: right"> <?php echo $numbers['Likes'], $voteup, " -- ", $numbers['Dislikes'], $votedn; ?> </div>
<br>Op datum: <?php echo $numbers['Day']," - ", $numbers['Month'], " - ", $numbers['Year']; ?>
<br> <?php echo $numbers['Views'], " keer bekeken"; ?>
<br><br>Beschrijving:
<br><?php echo $description; ?>
</td></tr></table>
<a href="index.html">Hoofdpagina</a>
<br><br>
<form action="" method="get"> <b>Ga naar een ander filmpje:</b>
<br><input type="text" name="v"> <input type="submit" value="Gaan!"> </form>
</center>
</body>
</html>