Jump to content

psquillace

Members
  • Posts

    94
  • Joined

  • Last visited

    Never

Posts posted by psquillace

  1. Ok mark this one as solved, i figured it out and I hope this little bit helps someone here.

     

    in PHP you cannot just say, if('pagename.htm') {echo "this stuff"}else{echo "that stuff"};

     

    you have to tell it what server you are on, and if you are, then if you are on this page, then can you do this.

     

    Here is an example of what I did to make this menu work for me.

     

    if($_SERVER['PHP_SELF'] == 'brand-name-playing-cards.php') {

    echo "<tr><td width=\"160\" height=\"15\" align=\"left\" style=\"background-color:#cfcfc7;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#cfcfc7';\"><a class=\"menu\" href=\"brand-name-playing-cards.htm\"><b>  Brand Name<br>  Playing Cards</b></a></td></tr>\n";

    }else{

    echo "<tr><td width=\"160\" height=\"15\" align=\"left\" style=\"background-color:#edede4;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#edede4';\"><a class=\"menu\" href=\"brand-name-playing-cards.htm\">  Brand Name Playing Cards</a></td></tr>\n

    <tr><td height=\"1\" class=\"navdivider\"><img src=\"images/spacer.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" width=\"160\" height=\"1\" alt=\"\"></td></tr>\n";

    }

  2. Ok Wait... it appears that I spoke to soon  ;D

     

    This is what I have now as an alternate -

     

    if('brand-name-playing-cards.htm') {
    		echo "<tr><td width=\"160\" height=\"15\" align=\"left\" style=\"background-color:#cfcfc7;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#cfcfc7';\"><a class=\"menu\" href=\"brand-name-playing-cards.htm\"><b>  Brand Name<br>  Playing Cards</b></a></td></tr>\n";
    		}else{
    		echo "<tr><td width=\"160\" height=\"15\" align=\"left\" style=\"background-color:#edede4;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#edede4';\"><a class=\"menu\" href=\"brand-name-playing-cards.htm\">  Brand Name Playing Cards</a></td></tr>\n
    		<tr><td height=\"1\" class=\"navdivider\"><img src=\"images/spacer.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" width=\"160\" height=\"1\" alt=\"\"></td></tr>\n";	
    }
    
    if('congress-playing-cards.php') {
    	echo "<tr><td width=\"16\" height=\"15\" align=\"left\" style=\"background-color:#cfcfc7;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#cfcfc7';\"><a class=\"menu\" href=\"congress-playing-cards.php\"><b>  Congress Playing Cards</b></a></td></tr>";
    	}else{
    	echo "<tr><td width=\"160\" height=\"15\" align=\"left\" style=\"background-color:#edede4;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#edede4';\"><a class=\"menu\" href=\"congress-playing-cards.htm\">  Congress Playing Cards</a></td></tr>
    	<tr><td height=\"1\" class=\"navdivider\"><img src=\"images/spacer.gif\" border=\"0\" hspace=\"0\" vspace=\"0\" width=\"160\" height=\"1\" alt=\"\"></td></tr>";
    }

     

    but for some reason, it is only picking up the else part no matter what page I am on. it also is not picking up my spacer image, is tehre a code for that that I need that is just for images or something.

     

    Thanks for any help or advice on this,

     

    Paul

  3. Yes that is complete even with the <!--#virtual include"DOCUMENT_NAME" -->

     

    it is not commonly used but it is all over this site that I have to edit to php so I am not sure how to change it. I tried this below just now but the text editor is complaining about something already. lOL

     

    <?php if('congress-playing-cards.php') {
    echo "<tr><td width=\"16\" height=\"15\" align=\"left\" style=\"background-color:#cfcfc7;\" onMouseOver=\"this.style.backgroundColor='#cfcfc7';\" onMouseOut=\"this.style.backgroundColor='#cfcfc7';\"><a class=\"menu\" href=\"congress-playing-cards.php\"><b>  Congress Playing Cards</b></a></td></tr>"
    }else{
    echo "<tr><td width="160" height="15" align="left" style="background-color:#edede4;" onMouseOver="this.style.backgroundColor='#cfcfc7';" onMouseOut="this.style.backgroundColor='#edede4';"><a class="menu" href="congress-playing-cards.htm">  Congress Playing Cards</a></td></tr>"
    }
    
    <tr><td height="1" class="navdivider"><img src="images/spacer.gif" border="0" hspace="0" vspace="0" width="160" height="1" alt=""></td></tr>

  4. Hello,

     

    I have changed most of my site over to php and now I have a problem. I did have virtual includes in html on my site that went like this

     

    <!--#if expr='("$DOCUMENT_NAME" = "gemaco-bridge-sets.htm")' --><tr><td width="160" height="15" align="left" style="background-color:#cfcfc7;" onMouseOver="this.style.backgroundColor='#cfcfc7';" onMouseOut="this.style.backgroundColor='#cfcfc7';"><a class="menu" href="gemaco-bridge-sets.htm"><b>  Gemaco Bridge Sets</b></a></td></tr>
    <!--#else -->
    <tr><td width="160" height="15" align="left" style="background-color:#edede4;" onMouseOver="this.style.backgroundColor='#cfcfc7';" onMouseOut="this.style.backgroundColor='#edede4';"><a class="menu" href="gemaco-bridge-sets.htm">  Gemaco Bridge Sets</a></td></tr>
    <!--#endif -->
    <tr><td height="1" class="navdivider"><img src="images/spacer.gif" border="0" hspace="0" vspace="0" width="160" height="1" alt=""></td></tr>

     

    Now my menu on my pages are broken and I do not know how to convert that to php.

     

    Basically I want to say, If we are on this page, then load the menu like this... if not, then this...

     

    I know it is an if else I just do not know how to say the if this page part like in html.

     

     

    Thanks for any help or advice on this,

     

    Paul

  5. Hello All:

     

    I created a simple login form for my site which I cannot get to work and I do not understand why.  The login page is a simple username and password page and it connects to the db and all works fine as far as logging in.

     

    It is when I want content blocked on other pages that is the problem.

     

    On the very top of those pages I have,

     

    session_start();
    
    if (!(isset($_SESSION['myusername']) && $_SESSION['mypassword'] != '')) {
    header ("Location: login.php");
    
    exit();
    }

     

    For some reason though, when I go to the home page after successfully logging in, I go to the login page again.

     

    The form action for that login is like this,

     

    session_start();
    
    $host="localhost"; // Host name
    $username="wholesale_admin"; // Mysql username
    $password="blackjack21"; // Mysql password
    $db_name="kardwell_wholesale"; // Database name
    $tbl_name="members"; // Table name
    
    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    // username and password sent from form
    $myusername=$_POST['myusername'];
    $mypassword=$_POST['mypassword'];
    
    // To protect MySQL injection 
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);
    
    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);
    
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row
    
    if($count==1){
    
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("myusername");
    session_register("mypassword");
    header("location:login_success.php");
    
    }else {
    
    echo include('wrong_username.htm');
    }
    

     

    Is there something I am doing wrong that someone can help me here get this working?

     

     

    Thanks for any help with this,

     

    Paul

     

     

  6. Hello All:

     

    I have started to make my .htaccess file so that my CMS will dynamically change the URL from one that is like this www.mydomain.com/info_page.php?page_id=$1&product=$2 to one that has a specific product on the end, like www.mydomain.com/oinons/bagels/coffee.

     

    The problem I am realizing was that I thought that I could just do this with just the .htaccess but now I am starting to see that you would need a php file or script to tell it what to change too.

     

    This is where I need the help because I am kind of new to php and would not even know where to begin with something like that.

     

    Can someone point me in the right direction or something so I can get this show on the road. :D

     

    Thanks,

     

    Paul

  7. Hello All,

     

    I worte this bit of code so that a few graphics I have online will change if in between 2 dates. It goes something like this:

     

    <?php
    
    
    if(time() > strtotime('1262930400') && time() < strtotime('1263427199')){
    
    	echo ('<tr><td align="center" valign="middle" colspan="2"><a href="http://www.raffledrums.com/acrylic-raffle-drums.htm"><img src="images/raffledrums_tn.jpg" border="0" hspace="0" vspace="5" width="238" height="98" alt="Giant Raffle Drums"></a></td></tr>');
    
    }else{
    
    echo ('<tr><td align="center" valign="middle" colspan="2"> </td></tr>');	
    }
    
    ?>

     

    However, it is not working correctly.

     

    Am I doing something wrong in there that I am missing?

     

    Thanks for the help and or advice on this,

     

    Paul

  8. Hello All:

     

    I am writing a php snip or at least trying too where if one radio button is selected we go to this URL otherwise go to this URL.

     

    I started something like this but I get lost real quick after that because I never did an if else with radio buttons before.

     

    Any help would be appreciated.

     

    <?php

     

    if ($radio1 'selected' ? "http://"){

    }else{

    "http://"

    }

     

     

    sorry for such a hack job on that above I just don't know that much about php...

     

     

  9. OK, I got it to go into the db with this code here

     

    $query .= mysql_escape_string($Company_Name) . "', '";

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

    $query .= "ORG', '"; //Write ORG if Filled In

    } else {

    $query .= "IND', '"; //Write IND if Not

    }

     

    I was using () when I should have used [], sheesh, I guess it is all in the learning process.

     

     

    Ok, but I have a new issue I am hoping someone here can help.

     

    It is not going into the right field in the db. It is just pushing all the other information forward and mis-alligning it all.

     

    what do I have to put in my code to get it to query into the right field is my question?

     

    Thanks for any help on this,

     

    Paul

     

  10. well, I changed the code a bit to read this instead

     

    $query .= mysql_escape_string($Company_Name) . "', '";

    if (isset($_POST($Company_Name))) {

    $query .= "ORG', '"; //Write ORG if Filled In

    } else {

    $query .= "IND', '"; //Write IND if Not

    }

     

    but I still get the white screen.

     

    I have this code before anything else in my php script

     

    ini_set ('display_errors', 'On');

    error_reporting (E_ALL);

     

    so I don't know why I would get no errors at all.

     

    Any thoughts on this,

  11. well, I only posted the part of the query that I inserted in there to show what I was trying to do. Here is the whole query so you can see what I did

     

    //Define the Query

    $queryx = "SELECT email FROM customer_table WHERE email='$email' LIMIT 1"; // Check if the email exists in the table

    $resultx = mysql_query($queryx);

    if (mysql_num_rows($resultx) > 0) {

    $message =  '<p><font color="red">Please use a different email address.</font></p>';

    } else {

    $query = "INSERT INTO customer_table "; // Insert into table 'customer_table'

    $query .= "(First_Name, Last_Name, Company_Name, Address_Line_1, City, State, Postal_Code, Country, Custom_Field_1, Custom_Field_2, Custom_Field_3, Optin, email, List_Array, Parent, Date) ";

    $query .= "VALUES ('";

    $query .= mysql_escape_string($First_Name) . "', '";

    $query .= mysql_escape_string($Last_Name) . "', '";

    $query .= mysql_escape_string($Company_Name) . "', '";

    if ($_POST($Company_Name) {

    $query .= "ORG', '"; //Write ORG if Filled In

    } else {

    $query .= "IND', '"; //Write IND if Not

    }

    $query .= mysql_escape_string($Address_Line_1) . "', '";

    $query .= mysql_escape_string($City) . "', '";

    $query .= mysql_escape_string($State) . "', '";

    $query .= mysql_escape_string($Postal_Code) . "', '";

    $query .= mysql_escape_string($Country) . "', '";

    $query .= mysql_escape_string($Custom_Field_1) . "', '";

    $query .= mysql_escape_string($Custom_Field_2) . "', '";

    $query .= mysql_escape_string($Custom_Field_3) . "', '";

    if ($Optin) {

    $query .= "1', '"; // Write a 1 if opted in

    } else {

    $query .= "0', '"; // Write a 0 if opted out

    }

    $query .= mysql_escape_string($email) . "', '"; // email is a unique field; the same email address will not be written to the table

    $query .= mysql_escape_string($trial) . "', '";

    $query .= mysql_escape_string($parentsite) . "', '";

    $query .= mysql_escape_string($today) . "');";

     

    //Execute the Query

    $result = mysql_query($query) or die(mysql_error()); // Run the query.

     

    if ($result) {

    $message =  '<p><font color="red">Your request has been added to our records.</font></p>';

    } else {

    $message =  '<p><font color="red">There was a problem writing your request to our records.</font></p>';

    // $message .= $query; for displaying the query for testing purposes

    }

    }

  12. Hello all,

     

    I have a form that when filled out, writes to a mysql database. One of these form fields is called Company_Name and I wanted to add and if else statement in my php code so that if Company_Name is filled in, in the form, it writes something else in a different part of the db.

     

    For example, if someone fills in Company_Name I have it capturing the company name the person fills out in the db.

     

    At the same time, I need an if else to write to a different part of the db if it is filled in or not.

     

    So far I have this but I do not think I am doing it right, Can someone tell me if this syntax is right or not?

     

               

    $query .= mysql_escape_string($First_Name) . "', '";

    $query .= mysql_escape_string($Last_Name) . "', '";

     

     

    $query .= mysql_escape_string($Company_Name) . "', '";

     

    if ($_POST($Company_Name) {

    $query .= "ORG', '"; //Write ORG if Filled In

    } else {

    $query .= "IND', '"; //Write IND if Not

    }

     

     

    $query .= mysql_escape_string($Address_Line_1) . "', '";

    $query .= mysql_escape_string($City) . "', '";

    $query .= mysql_escape_string($State) . "', '";

    $query .= mysql_escape_string($Postal_Code) . "', '";

    $query .= mysql_escape_string($Country) . "', '";

    $query .= mysql_escape_string($Custom_Field_1) . "', '";

    $query .= mysql_escape_string($Custom_Field_2) . "', '";

×
×
  • 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.