Im trying to figure out how to add some html code for two things one is a video album for my members and i have to add it to the funtions.php and the other is code for pets where members can buy ea other as pets but its in html and my site is mostly php i also want to change the messages to a better message system but i dont know how to recode my funtions to make the new code work
So ill post code for some ideas if someone thinks it can be done
thanks
Posted by Steve_Arm, 07-24-2008, 12:40 PM
You should post some code.
You can mix html and php code.
Posted by Jatinder, 07-24-2008, 12:49 PM
You have there options for generating dynamic HTML from PHP:
Embed PHP directly in HTML code.
Echo HTML from within PHP code
Use template system
A simple pseudo template file:
A template parser will then read this template file and replace template tags with some value. In the above pseudo template, {DATE} is a template tag.
Posted by greg2007, 07-25-2008, 02:00 AM
As you state "add html to php" I would guess your 'file' is mainly php. In that case you can simply 'end' php within the file, write some html, start php again.
If your file is mostly HTML, and only a few bits of PHP here and there, you might use Jatinder first example.
Remembering of course that if you have any php in a file, it has to be saved as a .php extention or it wont run.
Posted by Codebird, 07-25-2008, 04:09 AM
I previously used to echo html through php, but then found it easier and more controllable to embed php in html, so as an advice go with embedding php into html as Jatinder's first example
Posted by webcertain, 07-25-2008, 06:00 AM
you can also do things like;
now $stuff will contain the html code, which you can use whereever.
Posted by rumrunner439, 07-27-2008, 06:24 PM
oh wow im going to have to post some code i see, i currently use efriends by alstrasoft and after 6 months of working thur the bugs im almost thinking i should use phpfox 1.6.20 gee anyone got a copy
but i have tried to post my funtions.php but it had to many characters to post it here, and first i have to figure out how to fix my video_albums.php into the funtions
www.x1159.com also i need to fix my messages and photo albums and i have the better code but its html so i just have to figure out how to add it
thanks
Posted by rumrunner439, 07-27-2008, 06:26 PM
My video_albums.php ill have to post the funtions in two posts
require('data.php');
require('functions.php');
require('templates/language/eng.php');
sql_connect();
$act=form_get("act");
if($act==''){
//showing user's video album, depending on page
$p_id=form_get("p_id");
$m_id=cookie_get("mem_id");
$m_pass=cookie_get("mem_pass");
login_test($m_id,$m_pass);
$page=form_get("page");
if($page=='') $page=1;
show_header();
?>
echo name_header($p_id,$m_id); ?>'s Video Album
photo_album3($p_id,"$page",''); ?>
pages_line($p_id,"video_album","$page","5"); ?>
show_footer();
}//if
elseif($act=='view'){
global $videoa_id, $new_page_id;
//showing one selected photo
$domain = $_SERVER['HTTP_HOST'];
$link = "http://" . $domain . $_SERVER['REQUEST_URI'];
$videoa_id=form_get("videoa_id");
$p_id=form_get("p_id");
$m_id=cookie_get("m_id");
$sql_query="select videoalbum,vtitle,approve from videoalbum where mem_id='$p_id'";
$videoa=sql_execute($sql_query,'get');
$video=$videoa->videoalbum;
$approve=$videoa->approve;
$approve=if_empty($approve);
$vtitle=$videoa->vtitle;
show_header();
echo "
show_footer();
}//elseif
elseif($act=='trb_view'){
//showing one selected user photo
$pho_id=form_get("pho_id");
$trb_id=form_get("trb_id");
$sql_query="select name from tribes where trb_id='$trb_id'";
$name=sql_execute($sql_query,'get');
$sql_query="select photo,capture from tribe_photo where trb_id='$trb_id'";
$pho=sql_execute($sql_query,'get');
$photos=split("\|",$pho->photo);
//print_r($photos);
$photos=if_empty($photos);
$captures=split("\|",$pho->capture);
$captures=if_empty($captures);
//print_r($photos);
//echo $pho_id;
show_header();
echo "
".$name->name."
";
echo "
$captures[$pho_id]
";
show_footer();
}//elseif
*/
elseif($act=='del'){
global $base_path,$HTTP_REFERER;
$m_id=cookie_get("mem_id");
$m_pass=cookie_get("mem_pass");
login_test($m_id,$m_pass);
$pho_id=form_get("pho_id");
$sql_query="select videoalbum,vtitle from videoalbum where mem_id='$m_id'";
$videoa=sql_execute($sql_query,'get');
$video=$videoa->videoalbum;
$approve=$videoa->approve;
$approve=if_empty($approve);
$vtitle=$videoa->vtitle;
if(file_exists("$base_path/$videoa[$videoa_id]")) unlink("$base_path/$videoa[$videoa_id]");
/*
$sql_query="select videoalbum from members where mem_id='$m_id'";
$mem=sql_execute($sql_query,'get');
if($photos[$i]==$mem->photo){
$sql_query="update members set photo='',photo_b_thumb='',photo_thumb='' where mem_id='$m_id'";
sql_execute($sql_query,'');
}//if
*/
unset($videoa[$videoa_id]);
unset($vtitle[$videoa_id]);
unset($accept[$videoa_id]);
$line='';
$line2='';
$line3='';
$line4='';
foreach($videoa as $p){
$line.=$p."|";
}
$sql_query="update videoalbum set videoalbum='$line',
where mem_id='$m_id'";
sql_execute($sql_query,'');
show_screen($HTTP_REFERER);
}//elseif
?>
Posted by rumrunner439, 07-27-2008, 06:39 PM
First half of my funtions code
$conn_id;
$sql_res;
$sql_res2;
$sql_query;
$HTTP_REFERER=$_SERVER["HTTP_REFERER"];
$REQUEST_METHOD=$_SERVER["REQUEST_METHOD"];
function ConvertString($string) {
if (get_magic_quotes_gpc()) { $string = stripslashes($string); }
$string = htmlspecialchars($string,ENT_QUOTES);
$string = str_replace("'","'",$string); //2 passes is better than 1 :\
return trim(addslashes($string));
}
function sql_connect(){
global $conn_id,$sql_host,$sql_user,$sql_pass,$sql_db;
$conn_id=mysql_connect($sql_host,$sql_user,$sql_pass);
mysql_select_db($sql_db);
}
function sql_execute($sql_query,$wtr){
global $conn_id;
$sql_res=mysql_query($sql_query,$conn_id);
if($wtr=='get'){
if(mysql_num_rows($sql_res)){
return mysql_fetch_object($sql_res);
}
else {
return '';
}
}
elseif($wtr=='num'){
// echo $sql_query;
return mysql_num_rows($sql_res);
}
elseif($wtr=='res'){
return $sql_res;
}
}
function sql_rows($id,$table){
global $conn_id;
$query="select $id from $table";
$result=mysql_query($query,$conn_id);
$number=mysql_num_rows($result);
return $number;
}
function sql_close(){
global $conn_id;
mysql_close($conn_id);
}
function h_banners() {
global $cookie_url,$main_url;
$sql="select * from banners where b_blk='N' and b_typ='H' and b_exp='N'";
$res=mysql_query($sql);
$dis=array();
$dis_id=array();
$num=mysql_num_rows($res);
if(mysql_num_rows($res)) {
while($row=mysql_fetch_object($res)) {
$tmp=explode(".",$row->b_img);
$tmp_count=count($tmp);
$ext=strtolower($tmp[$tmp_count-1]);
if($ext=="swf") {
$img_s="";
} else $img_s="";
$dis[]="".$img_s."";
$dis_id[]=$row->b_id;
}
$tak=rand(0,$num);
$sql_query="select * from banners where b_id='$dis_id[$tak]'";
$num=sql_execute($sql_query,'num');
if($num!=0) {
$bann=sql_execute($sql_query,'get');
$d_f=date("d",$bann->b_f_day);
$m_f=date("m",$bann->b_f_day);
$y_f=date("Y",$bann->b_f_day);
$d_t=date("d",$bann->b_t_day);
$m_t=date("m",$bann->b_t_day);
$y_t=date("Y",$bann->b_t_day);
// $f_day=mktime(0,0,0,$m_f,$d_f,$y_f);
// $t_day=mktime(0,0,0,$m_t,$d_t,$y_t);
$f_day=mktime(0,0,0,$m_f,$d_f,$y_f);
$t_day=mktime(0,0,0,$m_t,$d_t,$y_t);
$today=mktime(0,0,0,date("m"),date("d"),date("Y"));
if(($bann->b_dur=="D") and ($today>$t_day)) {
delete_banner($dis_id[$tak]);
}
elseif($bann->b_dur=="C" and ($bann->b_ncl<=$bann->b_clks)) {
delete_banner($dis_id[$tak]);
}
elseif($bann->b_dur=="I" and ($bann->b_noi<=$bann->b_see)) {
delete_banner($dis_id[$tak]);
}
echo $dis[$tak];
for($i=0; $i<=$ip_co; $i++) {
mysql_query("update banners set b_see=b_see+1 where b_id='$dis_id[$tak]'");
}
}
}
}
function f_banners() {
global $cookie_url,$main_url;
$sql="select * from banners where b_blk='N' and b_typ='F' and b_exp='N'";
$res=mysql_query($sql);
$dis=array();
$dis_id=array();
$num=mysql_num_rows($res);
if(mysql_num_rows($res)) {
while($row=mysql_fetch_object($res)) {
$tmp=explode(".",$row->b_img);
$tmp_count=count($tmp);
$ext=strtolower($tmp[$tmp_count-1]);
if($ext=="swf") {
$img_s="";
} else $img_s="";
$dis[]="".$img_s."";
$dis_id[]=$row->b_id;
}
$tak=rand(0,$num);
$sql_query="select * from banners where b_id='$dis_id[$tak]'";
$num=sql_execute($sql_query,'num');
if($num!=0) {
$bann=sql_execute($sql_query,'get');
$d_f=date("d",$bann->b_f_day);
$m_f=date("m",$bann->b_f_day);
$y_f=date("Y",$bann->b_f_day);
$d_t=date("d",$bann->b_t_day);
$m_t=date("m",$bann->b_t_day);
$y_t=date("Y",$bann->b_t_day);
// $f_day=mktime(0,0,0,$m_f,$d_f,$y_f);
// $t_day=mktime(0,0,0,$m_t,$d_t,$y_t);
// $today=mktime(0,0,0,date("m"),date("d"),date("Y"));
$f_day=mktime(0,0,0,$m_f,$d_f,$y_f);
$t_day=mktime(0,0,0,$m_t,$d_t,$y_t);
$today=mktime(0,0,0,date("m"),date("d"),date("Y"));
if(($bann->b_dur=="D") and ($today>$t_day)) {
delete_banner($dis_id[$tak]);
}
elseif($bann->b_dur=="C" and ($bann->b_ncl<=$bann->b_clks)) {
delete_banner($dis_id[$tak]);
}
elseif($bann->b_dur=="I" and ($bann->b_noi<=$bann->b_see)) {
delete_banner($dis_id[$tak]);
}
echo $dis[$tak];
for($i=0; $i<=$ip_co; $i++) {
mysql_query("update banners set b_see=b_see+1 where b_id='$dis_id[$tak]'");
}
}
}
}
function mailing($to,$name,$from,$subj,$body) {
global $SERVER_NAME,$admin_mail;
$subj=nl2br($subj);
$body=nl2br($body);
$recipient = $to;
$headers = "From: $name <$from>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Return-Path: <$admin_mail>\n";
$headers .= "Content-Type: text/html;\n";
$headers .= "X-Mailer: PHP/" . phpversion();
ini_set("sendmail_from", $from);
mail("$recipient","$subj","$body","$headers","-r $from");
}
function form_get($value){
global $HTTP_POST_VARS,$HTTP_GET_VARS,$_SERVER;
$REQUEST_METHOD=$_SERVER["REQUEST_METHOD"];
if($REQUEST_METHOD=='POST')
$get_value=$HTTP_POST_VARS["$value"];
elseif($REQUEST_METHOD=='GET')
$get_value=$HTTP_GET_VARS["$value"];
return addslashes_deep($get_value);
}
function addslashes_deep($value) {
$value = is_array($value) ?
array_map('addslashes_deep', $value) :
addslashes($value);
return $value;
}
function cookie_get($name){
global $HTTP_COOKIE_VARS;
return $HTTP_COOKIE_VARS[$name];
}
//require file, depending on mode
function check($mode){
global $cookie_url,$main_url;
$modules=array("article","blog_url","blogs","calendar","chkuser","events","forums","help","im","iml","imv","join","listing","login","main","messages", "paypal","paystat","people_card","photo_album","privacy","profile","rank","recent_view","search","terms","tour","tribe","update_paypal","user","forgot ","tacs","widgets");
if(isset($mode))
if(in_array($mode,$modules))
$document=$mode.".php";
else
$document="main.php";
else
$document="main.php";
require("$document");
}
//require admin file, depending on mode
function ad_check($mode){
if(isset($mode)){
$document=$mode.".php";
}
else{
$document="main.php";
}
require("admin/$document");
}
//require calendar file, depending on mode
function cal_check($mode){
if(isset($mode)){
$document=$mode.".php";
}
else{
$document="calendar.php";
}
require("calendar/$document");
}
//printing java code for listing categories
function listing_cats_java($mod){
$sql_query="select * from categories";
$res=sql_execute($sql_query,'res');
while($cat=mysql_fetch_object($res)){
if($mod==1){
echo ";
listCategory.setDefaultOption('$cat->cat_id','$cat->cat_id');
listCategory.addOptions('$cat->cat_id','Select Subcategory','$cat->cat_id'";
}
elseif($mod==2){
$nex=$cat->cat_id+1;
echo "
listmessage_categoryId.setDefaultOption('$cat->cat_id','$nex');
listmessage_categoryId.addOptions('$cat->cat_id'";
}
$sql_query="select * from sub_categories where cat_id='$cat->cat_id'";
$res2=sql_execute($sql_query,'res');
while($sub=mysql_fetch_object($res2)){
echo ",'$sub->name','$sub->sub_cat_id'";
}//while
echo ");";
}//while
}//function
// Returnds the curent page number on a multipage display
function getpage(){
if(!isset($_GET['page'])) $page=1;
else $page=$_GET['page'];
return $page;
}
function getpages(){
if(!isset($_GET['page'])) $page=1;
else $page=$_GET['page'];
return $page;
}
//Displays the page numbers
function show_page_nos($sql,$url,$lines,$page){
$tmp =explode("LIMIT",$sql);
if(count($tmp)<1) $tmp =explode("limit",$sql);
$pgsql =$tmp[0];
include 'show_pagenos.php';
}
//Formats The Date
function format_date($date,$time=0){
$tmp =explode(" ",$date);
$date2 =explode("-",$tmp[0]);
$date =$date2[1]."-".$date2[2]."-".$date2[0];
if($time) return $date." ".$tmp[1];
else return $date;
}
//just printing listing cats list
function listing_cats($sel){
$sql_query="select * from categories";
$res=sql_execute($sql_query,'res');
while($cat=mysql_fetch_object($res)){
if($cat->cat_id=="$sel"){
echo "";
}
else{
echo "";
}
}//while
}//function
//admin header
function show_ad_header($adsess){
$mode=form_get("mode");
$act=form_get("act");
?>
Site Administration
if(($mode='listings_manager')&&($act=='edit')) {?>
} ?>
require('templates/ad_header.php'); ?>
}//function
//showing header
function show_header(){
global $site_name;
?>
=$site_name?>
$mode=form_get("mode");
$act=form_get("act");
$p_id=form_get("p_id");
if($p_id!="" && $mode=="people_card"){
$s = sql_execute("SELECT b.file,a.skin FROM profiles a,skin b WHERE a.mem_id='$p_id' AND b.id=a.skin","get");
if($s->skin==0)
$s->file=$p_id.".css";
if($s->skin!=1)
echo "file."\" type=\"text/css\" rel=\"stylesheet\">";
}
if($mode=="user"){
?>
}
elseif(($mode=='listing')&&($act=='create')){
?>
}
elseif((($mode=='listing')&&($act!='create')&&($act!='show')&&($act!='feedback'))||(($mode=='search')&&($act=='listing'))){
?>
}//elseif
?>
if (empty($mode)) require('templates/header.php');
else require('templates/header2.php');
?>
}
//showing footer
function show_footer(){
?>
require("templates/footer.php"); ?>
//sql_close();
}
//redirect
function show_screen($loc){
Header("Location: $loc");
exit;
}
//error reports
function error_screen($errid){
$sql_query="select * from errors where err_id='$errid'";
$err=sql_execute($sql_query,'get');
$error_line=$err->error;
$detailes_line=$err->detailes;
show_header();
require('error.php');
show_footer();
exit();
}
//complete pages
function complete_screen($comid){
$sql_query="select * from complete where cmp_id='$comid'";
$cmp=sql_execute($sql_query,'get');
$header_line=$cmp->complete;
$detailes_line=$cmp->detailes;
show_header();
require('complete.php');
show_footer();
exit();
}
//checkin user login info
function login_test($mem_id,$mem_pass){
global $conf;
$sql_query="select password,ban,mem_acc,amount,deducted from members where mem_id='$mem_id' and mem_id>0";
$num=sql_execute($sql_query,'num');
$mem=sql_execute($sql_query,'get');
//if password incorrect
$adsess=form_get("adsess");
if($adsess!="")
admin_test($adsess);
else {
$mode=form_get("mode");
$act=form_get("act");
$pack = sql_execute("SELECT package_amt,onetime,period,vphoto FROM member_package WHERE package_id='".$mem->mem_acc."'","get");
if(($num==0)||($mem_pass!=$mem->password)){
error_screen(0);
}
//if user banned
elseif($mem->ban=='y'){
error_screen(12);
}
if(!$pack->onetime && $pack->package_amt>0){
if((time()-$mem->deducted)>($pack->period*86400))
if($mem->amount>$pack->package_amt)
deduct($mem_id);
elseif(($mode!="user" && $act!="profile")&&($mode!="login" && $act!="home"))
error_screen(37);
}
$mem=sql_execute($sql_query,'get');
if(($mode!="user" && $act!="profile")&&($mode!="login" && $act!="home")&&($pack->package_amt>0))
if($mem->amount<$conf['min_balance'])
error_screen(39);
if($mode=="photo_album" && $pack->vphoto=='0')
error_screen(40);
//updating db (setting user in online mode)
$now=time();
$was=$now-60*20;
$sql_query="update members set current='$now' where mem_id='$mem_id'";
sql_execute($sql_query,'');
$sql_query="update members set online='off' where current < $was";
sql_execute($sql_query,'');
}
}
//checkin admin session key
function admin_test($session){
$time=time();
$interval=$time-3600*24;
$sql_query="delete from admin where started < $interval";
@sql_execute($sql_query,'');
$sql_query="select * from admin where sess_id='$session'";
$num=@sql_execute($sql_query,'num');
if($num==0)
error_screen(24);
}
//sending messages, depending on message id
function messages($to,$mid,$data){
global $system_mail,$site_name;
if($mid==7){
$subject=$data[0];
$body=$data[1];
$name=$data[2];
$from_mail=$data[3];
}//if
else{
$sql_query="select * from messages where mes_id='$mid'";
$mes=sql_execute($sql_query,'get');
$subject=$mes->subject;
$body=$mes->body;
//replacing templates
$body=ereg_replace("\|email\|","$data[0]",$body);
$body=ereg_replace("\|password\|","$data[1]",$body);
$body=ereg_replace("\|link\|","$data",$body);
$body=ereg_replace("\|subject\|","$data[0]",$body);
$body=ereg_replace("\|message\|","$data[1]",$body);
$body=ereg_replace("\|user\|","$data[0]",$body);
$subject=ereg_replace("\|email\|","$data[0]",$subject);
$subject=ereg_replace("\|password\|","$data[1]",$subject);
$subject=ereg_replace("\|link\|","$data",$subject);
$subject=ereg_replace("\|subject\|","$data[0]",$subject);
$subject=ereg_replace("\|message\|","$data[1]",$subject);
$subject=ereg_replace("\|user\|","$data[0]",$subject);
$name=$site_name;
$from_mail=$system_mail;
}//else
$subject=stripslashes($subject);
$body=stripslashes($body);
$sql_query="select notifications from members where email='$to'";
$num=sql_execute($sql_query,'num');
if($num>0){
$mem=sql_execute($sql_query,'get');
if($mem->notifications=='1'){
$stat=1;
}
else {
$stat=0;
}
}
else {
$stat=1;
}
if(($stat==1)||($mid<4)){
mailing($to,$name,$from_mail,$subject,$body);
}
}
//deleting empty values of array
function if_empty($data){
$flag=0;
if($data==''){
return '';
}//if
else{
$result=array();
$i=0;
foreach($data as $val){
if((isset($val))&($i!=0)&($val!="")){
//if(!$val){
$flag=1;
array_push($result,$val);
}//if
$i++;
}//foreach
if($flag==0){
return '';
}//elseif
else {
return $result;
}//else
}//else
}//function
function if_empty1($data){
$flag=0;
if($data==''){
return '';
}//if
else{
$result=array();
$i=0;
foreach($data as $val){
if($val){
//if(!$val){
$flag=1;
array_push($result,$val);
}//if
$i++;
}//foreach
if($flag==0){
return '';
}//elseif
else {
return $result;
}//else
}//else
}//function
//showing country drop-down list
function country_drop(){
?>
}
//days drop-down list
function day_drop($sel){
for($i=1;$i<=31;$i++){
if($i==$sel){
echo "
Posted by rumrunner439, 07-27-2008, 06:41 PM
second half of my funtions now i have to figure out how to get the video_albums.php to work right now all im getting is a login screen with my video_albums.php
}//function
//showing number of new discussion board posts since last user's visit
function tribe_new_posts($mem_id,$trb_id){
$visit=cookie_get("$trb_id");
if($visit==''){
$visit=0;
}
$sql_query="select top_id from board where trb_id='$trb_id' and added>$visit";
$num=sql_execute($sql_query,'num');
if($num==0){
return "no new posts";
}//if
else {
return "$num new posts read";
}//else
}//function
//returns tribe's members array
function tribe_members($trb_id){
$sql_query="select members from tribes where trb_id='$trb_id'";
$trb=sql_execute($sql_query,'get');
//$trb->members=$trb->members."|";
$members=split("\|",$trb->members);
//echo $members[0];
$members=if_empty1($members);
return $members;
}//function
//shows tribe members
function show_members($trb_id,$limit,$inline,$page){
$members=tribe_members($trb_id);
if($members!=''){
$start=($page-1)*$limit;
$end=$start+$limit;
if($end>count($members)){
$end=count($members);
}
for($i=$start;$i<$end;$i++){
$frd=$members[$i];
if(($i==0)||($i%$inline==0))
{
echo "
";
}//if
echo "
";
echo "
";
show_photo($frd);
echo "
";
show_online($frd);
echo "
";
}//foreach
}//if
else {
echo "
No members.
";
}//else
}//function
//showing topics of tribe discussion board
function show_board($trb_id){
$sql_query="select * from board where trb_id='$trb_id'";
$res=sql_execute($sql_query,'res');
echo "
Topic
Author
Replies
Last Post
";
while($brd=mysql_fetch_object($res)){
$sql_query="select rep_id,added from replies where top_id='$brd->top_id' order by added desc";
$num=sql_execute($sql_query,'num');
$res2=sql_execute($sql_query,'res');
$one=mysql_fetch_object($res2);
if($one->added==''){
$one->added=$brd->added;
}
$last_post=date("m/d/Y",$one->added);
echo "