Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 09-17-2012, 06:03 PM
deadlySniper deadlySniper is offline
 
Join Date: Dec 2008
Location: New York
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom Database Submittion

I have made my own vbulletin powered page (link) and it only allows certain usergroups to access it. Basically the page is used to submit data to a database that is on another server. I have made a couple of php scripts that do all of this but every time I submit it, it gives syntax errors. Now if I move everything into its own directory and use them as normal php files, they work fine. So I dont know what I am doing wrong with vbulletin part.

The data.php contains the connection to the database.

vbulletin page
Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
    {vb:raw headinclude_bottom}
  </head>
  <body>
    
    {vb:raw header}
    
    {vb:raw navbar}
    
    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>

    
    <h2 class="blockhead">Title</h2>
    <div class="blockbody">
      <div class="blockrow">
<vb:if condition="$show['guest']">
<span style="color:red; font-weight:bold;">You are a guest and not part of Admin Team</span>

<vb:elseif condition="is_member_of($bbuserinfo, 6,7)" />
<form name="whitelist" method="post" action="http://survivedayz.com/whitelist/connection.php">
<p><label>GUID</label><br />
<input type="text" name="guid" /></p>
<p><label>In-game Name</label><br />
<input type="text" name="name" /></p>
<input type="submit" name="submit" value="Submit" />
<INPUT TYPE="button" VALUE="Write New Whitelist" ONCLICK="window.location.href='http://survivedayz.com/whitelist/writewhitelist.php'"">
</form>

<vb:else />
<span style="color:red; font-weight:bold;">You must be part of the Admin Team to view this page</span>

</vb:if>
     

      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>
connection.php
Code:
<?php

include('data.php');
$name = $_POST['name'];
$guid = $_POST['guid'];

//Database Connection
$con=@mysql_connect("$ip", "$user", "$pass")
			or die(mysql_error());
			
//Select Database
$dbcon=@mysql_select_db($db, $con)
			or die(mysql_error());

//Query Data Into Whitelist Table
$sql="INSERT INTO $table (name, guid) VALUES ('$name', '$guid')";

//Submit Data into Whitelist Table
$result=@mysql_query($sql, $con) or die(mysql_error());

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>White List Updated</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "3000";
redirURL = "http://survivedayz.com/forums/whitelist.php";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
</script>
<style type="text/css">
#space {
	padding-left: 20px;
	padding-right: 20px;
}
#guid {
	color:#FF0000;
	font-weight:bold;
	}
#name {
	color:#00FF00;
	font-weight:bold;
body {
	background:#000;
	}

</style>
</head>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<body>

<table>
<td id="guid">
GUID: <? echo "$guid"; ?>
</td>
<div id="space">-</div>
<td id="name">
Username: <? echo "$name"; ?>
</td>
</tr>
</table>
</body>
</html>
writewhitelist.php
Code:
<?php

include('data.php');


//Database Connection
$con=@mysql_connect("$ip", "$user", "$pass")
			or die(mysql_error());
			
//Select Database
$dbcon=@mysql_select_db($db, $con)
			or die(mysql_error());
			
$sql="SELECT guid, comments FROM $table ORDER BY id INTO OUTFILE 'whitelist.txt' LINES TERMINATED BY '\n'";

$result=@mysql_query($sql, $con) or die(mysql_error());
		
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>White List Updated</title>

<style type="text/css">
#space {
	padding-left: 20px;
	padding-right: 20px;
}
#guid {
	color:#FF0000;
	font-weight:bold;
	}
#name {
	color:#00FF00;
	font-weight:bold;
body {
	background:#000;
	}

</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "3000";
redirURL = "http://survivedayz.com/forums/whitelist.php";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
</script>
</head>

<body onLoad="redirTimer()">

<p id="guid">File Has Been Written</p>
</body>
</html>
Reply With Quote
  #2  
Old 09-18-2012, 02:33 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not quite sure what you're asking. What syntax errors are you getting?

The only thing I noticed while looking over what you posted is that this line in the vbulletin page:
Code:
<INPUT TYPE="button" VALUE="Write New Whitelist" ONCLICK="window.location.href='http://survivedayz.com/whitelist/writewhitelist.php'"">

has an extra double quote at the end.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:00 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03595 seconds
  • Memory Usage 2,181KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete