Jump to content

Recommended Posts

Alright I've racked my brain over and over, and to me it seems completely illogical that this isn't fucking working. At this point I'm starting to get angry and I really need someone to explain to me why this doesn't work because I refuse to move on in my studies until I figure this out. I would really appreciate it. note: I didn't post this in regex because it's nothing to do with the regex really.

 

 

Everything works just golden except the last if statement. If I enter say "a"" in the facebook form, it will return "a", instead of: "facebook.com/a". I seriously cannot fathom why and need help. I've tried else, elseif, if in varying orders thinking maybe I just lack understanding of them but no. So that's why I have it currently placed idioticly in 3 if statements.

 

<?php
$first_name = trim($_REQUEST['first_name']);
$last_name =  trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);

$facebook_url = trim($_REQUEST['facebook_url']);
$facebook_url_check = false;
if (preg_match("/facebook.com\/|facebook.org\/|facebook.net\//", $facebook_url)) {
	$facebook_url_check = true;
}

if ($facebook_url_check = true) {
	$facebook = preg_replace("/facebook.org\/|facebook.net\//i", 
	"facebook.com/", $facebook_url);
}
if ($facebook_url_check = false) {
		$url = "facebook.com/";
		$facebook = $url . $facebook_url;
	}
?>

Link to comment
https://forums.phpfreaks.com/topic/256988-i-think-ill-snap-my-keyboard/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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