PHP - Stop If Statement From Working Onload
The code belows stops sql queries from being executed when there are blank fields on my form.
Aswell as this, a message is displayed '<br> but you did not complete all of the required fields, please try again' How can I tell me page to check the fields upon pressing the click button, opposed to onload? Code: [Select] <?php include('func.php'); include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <!--$INC_DIR = $_SERVER["DOCUMENT_ROOT"]. "/include/";--> <!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>Chained Select Boxes using PHP, MySQL and jQuery</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> </head> <body> <p> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Name: <input type="text" name="Name" maxlength="50"/><br /> Phone: <input type="text" name="Phone" maxlength="50"/><br /> Email: <input type="text" name="Email" maxlength="50"/><br /> Postcode: <input type="text" name="Postcode" maxlength="50"/><br /> Web Address: <input type="text" name="Website" maxlength="50"/><br /><br /> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; } $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '' || $Phone == '' || $Email == '' || $Postcode == '' || $Website == '') { die('<br> but you did not complete all of the required fields, please try again'); } echo "<br>"; echo $Name; echo "<br>"; echo $Website; $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `Web Address`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); ?> </body> </html> Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=319472.0 I'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. Friends, I have a code to filter out stopwords (from text file) out of a string supplied. Seems its not filtering out the stop words. Code: [Select] <?php $CommonWords = file_get_contents('http://minimate.co.uk/stopwords.txt'); $CommonWords = explode("\n", $CommonWords); $keywords = 'This is did samle a as any ass'; $search_keywords = strtolower(trim($keywords)); $arrWords = explode(' ', $search_keywords); $arrWords = array_unique($arrWords); foreach ($arrWords as $word) { if (!in_array($word, $CommonWords) && (trim($word) != '')) { $searchWords[] = $word; } } print_r($searchWords); ?> Output is: Quote Array ( => this [1] => is [2] => did [3] => sample [4] => a [5] => as [6] => any [7] => ass ) So the output is not filtering out any words from that text file. Can someone help me with this? Cheers Natasha T The pre tags: <pre></pre>get saved in the database like in the above shown example. Though, when reopening them within a textarea they stop working. For example: <pre><h1>The Headline</h1></pre>becomes: The Headline within the textarea. The Questions: What happens here? How to solve it? Edited by glassfish, 03 October 2014 - 09:42 AM. On all my forms, after I send an empty string to one field, it will stop accepting values when I resubmit. My code passes through the W3C validator Any ideas?? Hello guys, I am having an issue with my if statement. Basically what I am trying to do is when there are no photos uploaded then enter default image. Like I said doesn't look like my if stmt is working at all.. Any ideas? foreach (glob("temp_photo/$subn*.*") as $filename) { //echo "$filename<br>"; $string = $filename; $filename2 = basename($string); if($filename2 == ""){ $filename2="/images/default.jpg"; } // Insert ad details into mysql $query = "INSERT INTO ads (ad_type,ad_title,ad_body,ad_category,ad_photo,ad_member,ad_status,ad_city,ad_state,ad_zip)VALUES('".$ad_type."','".$ad_title."','".$ad_body."','".$catid."','".$filename2."','".$vname."','".$ad_status."','".$city."','".$state."','".$zip."')"; // Error checking to see if the query was successful $result = mysql_query($query) or die (mysql_error()."in <br>$query" ); i have been trying to figure this out for the last hour with no luck i am hopeing some one here can help me the problem is well i really dont know what the problem is but the code should check is the passwords match if they dont it will tell you to reenter your password if(isset($_POST['Submit'])) //isset open { $pass1=$_POST['pass1']; $pass2=$_POST['pass2']; if($pass1 != o) //pass open { echo"<style type='text/css'> <!-- body { background-color: #FFFFFF; } body,td,th { color: #000000; } --> </style></head> <body> <table width='100%' border='1'> <tr> <td><center>Your Password Did Not Match Please Reenter Your Passwrods</center></td> </tr> <tr> <td><form id='form1' name='form1' method='post' action=''> <label>Password <input type='text' name='pass1' id='pass1' /> </label> </td> </tr> <tr> <td> <label>Enter Password Again <input type='text' name='pass2' id='pass2' /> </label> </td> </tr> <tr> <td> <label> <center><input type='submit' name='Submit' id='Submit' value='Submit' /></center> </label> </form> </td> </tr> </table> </body>"; die(); //pass colse } else //pass else open { echo" <form name='redirect'> <center> <font face='Arial'><b>Your Account Has Been Validated You Will Now Be Redirect To The Admin Home Page in<br><br> <form> <input type='text' size='3' name='redirect2'> </form> seconds</b></font> </center> <script> <!-- //change below target URL to your own var targetURL='/test1' //change the second to start counting down from var countdownfrom=5 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout('countredirect()',1000) } countredirect() //--> </script>"; //pass else close } //isset close } So the issue I'm having here is that when champion_id, contender1_id, contender2_id, and contender3_id values are 0 then it DOES NOT echo Vacant and TBD as it should be, however when they are values other than 0 then it does correctly show the person's name. What am I doing wrong for it to not display the Vacant or TBD? Code: [Select] $query = "SELECT titles.title_name, titles.id, title_champions.champion_id AS champion_id, title_champions.contender1_id AS contender1_id, title_champions.contender2_id AS contender2_id, title_champions.contender3_id AS contender3_id, champion.character_name AS champion, contender1.character_name AS contender1, contender2.character_name AS contender2, contender3.character_name AS contender3 FROM title_champions LEFT JOIN titles ON title_champions.title_id = titles.id LEFT JOIN characters AS champion ON title_champions.champion_id = champion.id LEFT JOIN characters AS contender1 ON title_champions.contender1_id = contender1.id LEFT JOIN characters AS contender2 ON title_champions.contender2_id = contender2.id LEFT JOIN characters AS contender3 ON title_champions.contender3_id = contender3.id ORDER BY titles.title_name"; $result = mysqli_query ( $dbc, $query ); // Run The Query Code: [Select] <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo '<tr><td>' . $row['title_name'] . '</td><td>'; if($row['champion_id'] !== 0){echo $row['champion'];}else{echo "Vacant";} echo '</td><td>'; if($row['contender1_id'] !== 0){echo $row['contender1'];}else{echo "TBD";} echo '</td><td>'; if($row['contender2_id'] !== 0){echo $row['contender2'];}else{echo "TBD";} echo '</td><td>'; if($row['contender3_id'] !== 0){echo $row['contender3'];}else{echo "TBD";} echo '</td><td style="text-align:center;"><img src="img/notepad.png" class="edit" rel="' . $row['id'] . '"/></td></tr>'; } ?> $sql_my_workers = mysql_query("SELECT * FROM Worker WHERE mem_id='$id'"); $my_workers_result = mysql_num_rows($sql_my_workers); while($get_my_workers = mysql_fetch_array($sql_my_workers)){ $my_worker_firstname = $get_my_workers['firstname']; $my_worker_lastname = $get_my_workers['lastname']; $my_worker_age = $get_my_workers['age']; $my_worker_yearspro = $get_my_workers['yearspro']; $my_worker_promotion = $get_my_workers['promotion']; if ($my_workers_result < 1){ $my_workers = " <p class='text' align='center'>You have not created any workers.</p> "; } else { $my_workers .= " <div class='worker_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$my_worker_firstname $my_worker_lastname</p> </div> <div class='worker_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$my_worker_age</p> </div> <div class='worker_promo' align='center'> <p class='text3' style='font-weight: bold; '>Promotion</p> <p class='text3'>$my_worker_promotion</p> </div> <div class='worker_contract' align='center'> <p class='text3' style='font-weight: bold; '>Contract</p> <p class='text3'>-</p> </div> <div class='worker_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$my_worker_yearspro</p> </div> <div class='line'></div>"; } } // connect to the database include_once ("Scripts/mysql_db_connect.php"); // get free agents $sql_free_agents = mysql_query("SELECT * FROM Worker WHERE mem_id!='$id'"); $free_agents_result = mysql_num_rows($sql_free_agents); while($get_free_agents = mysql_fetch_array($sql_free_agents)){ $free_agent_firstname = $get_free_agents['firstname']; $free_agent_lastname = $get_free_agents['lastname']; $free_agent_age = $get_free_agents['age']; $free_agent_yearspro = $get_free_agents['yearspro']; if ($free_agents_result < 1){ $free_agents = "<p class='text'>There are no free agents.</p>"; } else { $free_agents .= "<div class='fa_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$free_agent_firstname $free_agent_lastname</p> </div> <div class='fa_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$free_agent_age</p> </div> <div class='fa_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$free_agent_yearspro</p> </div> <div class='fa_previouspromo' align='center'> <p class='text3' style='font-weight: bold; '>Previous Promotion</p> <p class='text3'>-</p> </div> <div class='fa_reasonleftpromo' align='center'> <p class='text3' style='font-weight: bold; '>Reason for Leaving</p> <p class='text3'>-</p> </div> <div class='fa_salary' align='center'> <p class='text3' style='font-weight: bold; '>Salary</p> <p class='text3'>-</p> </div> <div class='line'></div>"; } } When I do the if < 1 statement, it comes back blank. The if $my_workers_result comes back as showing 0. So it should do that if statement, but yet it doesn't, its just blank. What am I doing wrong? Hi there im having trouble with my If statement in that its not doing what it is suppose to do! I have a do loop that and If statament that checks that resultp < results. If it is less then an echo is suppose to happen, but its not. Im getting notice errors: Undefined index: Class1- 4 but nothing is outputted. I checked the records in the database so the condition will happen but nothings happening. Help Code: [Select] <?php do { ?> <?php echo $row_resultp['Class1_totla']; echo ' Class 1'; echo'<br>'; echo $row_resultp['Class2_totla']; echo ' Class 2'; echo'<br>'; echo $row_resultp['Class3_totla']; echo ' Class 3'; echo'<br>'; echo $row_resultp['Class4_totla']; echo ' Class 4'; echo'<br>';echo'<br>';echo'<br>'; echo $row_results['Class1_totlas']; echo ' Class 1'; echo'<br>'; echo $row_results['Class2_totlas']; echo ' Class 2'; echo'<br>'; echo $row_results['Class3_totlas']; echo ' Class 3'; echo'<br>'; echo $row_results['Class4_totlas']; echo ' Class 4'; if ($row_resultp['Class1'] < $row_results['Class1']){ echo 'you need'; echo $row_resultp['Class1'] - $row_results['Class1']; echo 'more'; } if ($row_resultp['Class2'] < $row_results['Class2']){ echo 'you need'; echo $row_resultp['Class2'] - $row_results['Class2']; echo 'more';} if ($row_resultp['Class3'] < $row_results['Class3']){ echo 'you need'; echo $row_resultp['Class3'] - $row_results['Class3']; echo 'more'; } if ($row_resultp['Class4'] < $row_results['Class4']){ echo 'you need'; echo $row_resultp['Class4'] - $row_results['Class4']; echo 'more'; } ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp) && ($row_results = mysql_fetch_assoc($results))); ?> now i am trying to get this to work it should change the variable if the statement is ture and it not in that and any one help include'db.php'; $sql2=mysql_query("SELECT * FROM site_config WHERE id=1")or die(mysql_error()); while($row2=mysql_fetch_array($sql2)) { $paypal_email=$row2['paypal_email']; $price=$row2['price']; $sandbox=$row2['sandbox']; $account_number=$row2['account_number']; $quantity_1=$row2['quantity_1']; $product=$row2['product']; $return_url=$row2['return_url']; $demo=$row2['demo']; if($sandbox==1) { $link='http://www.sambob.info'; if(empty($sandbox)) { $link='http://www.bob.tdsnet.org'; } echo"$link<br>$sandbox"; } } $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3"; Any ideas? Ok, a bit of a background into my code, It runs off of 2 different passing variables, I have it set up with multiple if() statements to do certain things based on the inputs... Here is a snipet of my code if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "") { $postal = $_REQUEST['postal']; $lbs = $_REQUEST['lbs']; $type = $_REQUEST['type'] if ($type == "splist") { $ztype = "cansp_zone" ; } else { $ztype = "canmp_zone"; } Obviously not the whole thing, Now what you see is line 18-26 of a 216 line document. The nested if statement is what is causing the problem, I get a "syntax error, unexpected T_IF" on line 22, the "if ($type)" line. Now theoretically, if I did not pass the variables (in which case the primary if statement would be false) It should bypass this whole section, however its not. Any ideas? I am thinking its not actually doing the verification and outputting the error because type is not defined. Absolutely no idea why my IF statement's playing up - needs some fresh eyes I think! if ($postcheck != $post){ if ($x == "0"){ echo $title; echo "<br>"; $x = "1"; $y = $y + 1; } echo "Change Post to: "; echo $postcheck; echo " from "; echo $post; echo "<br>"; $result2 = mysql_query("UPDATE items SET Post='$postcheck' WHERE ID='$id'") or die(mysql_error()); } When it returns $postcheck and $post, in this case, they're coming out as the same thing (on one record - no others!) - $post is retrieved from a database, and $postcheck is calculated. Both are numbers. Any ideas?! what i'm trying to do, is have it so a staff member can mange users i came up with these, but it dosn't show on the page :S if ( isadmin ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an admin. You may <a href="manage_users.php" title="manage users">manage users</a> or <a href="admin_settings.php" title="edit site settings">edit site settings</a>. <? if ( ismod ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an mod. You may <a href="manage_users.php" title="manage users">manage users</a>. <?php endif; ?> Hello Everyone, From time to time, I get into a situation where my if statements do not give the desired results. I always have to play around with them to get the things working. I'm in same situation right now. I'm guessing that I do not completely understand the logic. If someone can take a look at the code below and tell me what's wrong, it will be greatly appreciated. if($_SESSION['account_type'] != 'internal admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } elseif($_SESSION['account_type'] != 'super admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } I have echoed out the $_SESSION['account_type'] and I'm getting "internal admin" but for some reason, I'm getting the error "Error: This page can only be accessed by internal or super admin." Thanks in advance for your help. Jatt Surma Ok I have a new issue, and for the life of me, I cannot figure out where I went wrong, in my head it looks sound, but it does not seem to really work. I get no errors, but it does not work. if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] == "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != '') { } elseif ($_REQUEST['postal'] == "" && $_REQUEST['lbs'] != "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != '') { // THis is the problem right here.... // } elseif ($_REQUEST['postal'] == "" && $_REQUEST['lbs'] == "" && ($_REQUEST['length'] == "" || $_REQUEST['width'] == "" || $_REQUEST['height'] != '')) { } elseif ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "" && $_REQUEST['length'] != "" && $_REQUEST['width'] != "" && $_REQUEST['height'] != "") { } else { } The Second elseif is the issue. If I enter the postal and weight, it should go to that if else and execute its code, because I left all the length, height and width blank. But in stead it goes to the last else. What I am looking to do is that if any of the length, width, or height is not entered, then it comes back with an error... But it does not seem to pick up on it. ANy help would be appreciated. [EDIT] I swear I looked at it 50 times and didn't see it... I go and make my post, re-read it and realize my operators were all wrong... [makes action of smaking slef in head] [/EDIT] Believe me!! I have looked and tried so many snippets of code I am exausted! TableName: keywords Row: id productid keywords Good morning... I have been struggling with update, I dont know why... it seems easy eneough and it dosent look that different than a simple insert. Would someone please take a look at the if statement below, more specificly the update section. I am getting an error (Parse error: syntax error, unexpected T_STRING in...... ). Code: [Select] <? $keywd = substr(implode(",", array_keys($arr_tem)),0,200); $productid = intval($_GET['product_id']); // Make a MySQL Connection mysql_connect("localhost", "xxxxxxxxx", "xxxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxxx") or die(mysql_error()); $get = "SELECT * FROM keywords WHERE productid = $productid"; $SQ_query = mysql_query($get) or die("Query failed: $get\n" . mysql_error()); $fetch = mysql_fetch_array($SQ_query); $id = $fetch['productid']; $key = $fetch['keywords']; // Evaluates to true because $var is empty if (empty($id)) { mysql_query("insert into keywords (productid, keywords) VALUES('$productid','$keywd')"); } else{ if (isset($id)) { echo '$var is set even though it is empty'; $mysql_query = mysql_query(UPDATE keywords SET keywords = '$keywd' WHERE productid = '$productid'); // $mysql_query = mysql_query(UPDATE keywords set keywords = "$keywd" WHERE productid = "$productid"); } endif; ?> Hi I have a page pulling information from mysql table, it lists names, I have these inside a hyperlink so that where there is a website listed for that record then the user can click on the name and move to their website. Only thing is that what happens if there is not a website for that record. I wanted a script so that if there is a website address listed then it prints the hyperlink but where there is not a website address listed that only the name is printed and it is not a hyperlink. I understand that the strpos can be used for this I have written a script but it is only printing out the name even when there is a website address in the row. What is wrong? PHP Version 5.3.4 Any help very much appreciated Code: [Select] <?php $website = $org_website; $link = 'http'; $weblink = strpos ($website,$link); if ($weblink === !false) { echo "<a href=\"$org_website;\"> FindOrganiserName($org_id); \"> FindOrganiserName($org_website); </a>"; } else { echo FindOrganiserName($org_id); } ?> For some reason this just isn't inserting... HTML snippet: Code: (HTML) [Select] <form name="testimonials_form" method="post" action="insert/"> Name <input type="text" name="from" maxlegnth="100" /> Location <input type="text" name="where" maxlegnth="100" /> Text Snippet <input type="text" name="text" maxlegnth="255"> <input type="submit" name="submit" value="Continue" /> </form> PHP Snippet: Code: (PHP) [Select] <?php $from = $_POST['from']; $where = $_POST['where']; $text = $_POST['text']; if (!$from || !$where || !$text) { $error = "You have missed some fields."; $solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>."; } else { $data_array = array( ':from' => $from, ':where' => $where, ':text' => $text); $insert_testimonial = $connect->prepare("INSERT INTO `testimonials` (text, from, where) VALUES (:text, :from, :where)"); $insert_testimonial->execute($data_array); $amount = $insert_testimonial->rowCount(); if ($amount < 1) { $error = "Something went wrong."; $solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>."; } else { header ("Location: ../"); } } ?> All I keep getting back is my custom error "Something went wrong." so there's no 500 error (internal server error) and if I echo $from, $where and $text it displays what I typed in the form, I've re-written it about 5 times in case I wrote it wrong or something but still no luck. I know there can't be a symbol missing or in the wrong place since it would return a 500 error. Does anyone have any clue as to what's up with it? I've written codes like this countless times but this just doesn't seem to be working, so I must be missing something. |